public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Stephen Hemminger <shemming@brocade•com>
To: Beniamino Galvani <bgalvani@redhat•com>
Cc: "netdev@vger•kernel.org" <netdev@vger•kernel.org>
Subject: Re: [iproute2 PATCH] utils: fix hex digits parsing in hexstring_a2n()
Date: Tue, 14 Jun 2016 14:25:50 -0700	[thread overview]
Message-ID: <20160614142550.12a8cf76@xeon-e3> (raw)
In-Reply-To: <80a1168c78944f39ab2b270df68ad9e5@HQ1WP-EXMB11.corp.brocade.com>

On Tue, 14 Jun 2016 20:55:17 +0000
Beniamino Galvani <bgalvani@redhat•com> wrote:

> strtoul() only modifies errno on overflow, so if errno is not zero
> before calling the function its value is preserved and makes the
> function fail for valid inputs; initialize it.
> 
> Signed-off-by: Beniamino Galvani <bgalvani@redhat•com>
> ---
>  lib/utils.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/lib/utils.c b/lib/utils.c
> index 70e85b7..7dceeb5 100644
> --- a/lib/utils.c
> +++ b/lib/utils.c
> @@ -924,6 +924,7 @@ __u8 *hexstring_a2n(const char *str, __u8 *buf, int blen, unsigned int *len)
>  
>  		strncpy(tmpstr, str, 2);
>  		tmpstr[2] = '\0';
> +		errno = 0;
>  		tmp = strtoul(tmpstr, &endptr, 16);
>  		if (errno != 0 || tmp > 0xFF || *endptr != '\0')
>  			return NULL;

Applied.
The code here is doing things in a manner much harder than necessary...

       reply	other threads:[~2016-06-14 21:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <80a1168c78944f39ab2b270df68ad9e5@HQ1WP-EXMB11.corp.brocade.com>
2016-06-14 21:25 ` Stephen Hemminger [this message]
2016-06-14 20:55 [iproute2 PATCH] utils: fix hex digits parsing in hexstring_a2n() Beniamino Galvani

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160614142550.12a8cf76@xeon-e3 \
    --to=shemming@brocade$(echo .)com \
    --cc=bgalvani@redhat$(echo .)com \
    --cc=netdev@vger$(echo .)kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox