On 11/7/22 08:30, liangmc1 wrote:
> When the input character string is a number greater than UINT_MAX,it
> should return an error.
>
> Signed-off-by: liangmc1 <[email protected]>
Hi. Thanks for the patch!
Typically the sign-off tag should be in a 'Firstname Lastname <email>'
format.
> ---
> lib/ofp-parse.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/lib/ofp-parse.c b/lib/ofp-parse.c
> index a90b926ef..6d6a79bcc 100644
> --- a/lib/ofp-parse.c
> +++ b/lib/ofp-parse.c
> @@ -71,16 +71,13 @@ str_to_u16(const char *str, const char *name, uint16_t
> *valuep)
> char * OVS_WARN_UNUSED_RESULT
> str_to_u32(const char *str, uint32_t *valuep)
> {
> - char *tail;
> uint32_t value;
>
> if (!str[0]) {
> return xstrdup("missing required numeric argument");
> }
>
> - errno = 0;
> - value = strtoul(str, &tail, 0);
> - if (errno == EINVAL || errno == ERANGE || *tail) {
> + if (!str_to_uint(str, 0, &value)) {
While this will work on most of the systems, uint is not necessarily
32bit long. We should probably still parse using a larger type here
and then check the range to be within [0 : UINT32_MAX].
> return xasprintf("invalid numeric format %s", str);
> }
> *valuep = value;
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev