From: Beniamino Galvani <bgalvani@redhat.com>
To: netdev@vger.kernel.org, Stephen Hemminger <shemming@brocade.com>
Subject: [iproute2 PATCH] utils: fix hex digits parsing in hexstring_a2n()
Date: Tue, 14 Jun 2016 22:55:17 +0200 [thread overview]
Message-ID: <1465937717-16247-1-git-send-email-bgalvani@redhat.com> (raw)
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;
--
2.5.5
next reply other threads:[~2016-06-14 20:55 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-14 20:55 Beniamino Galvani [this message]
[not found] <80a1168c78944f39ab2b270df68ad9e5@HQ1WP-EXMB11.corp.brocade.com>
2016-06-14 21:25 ` [iproute2 PATCH] utils: fix hex digits parsing in hexstring_a2n() Stephen Hemminger
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=1465937717-16247-1-git-send-email-bgalvani@redhat.com \
--to=bgalvani@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=shemming@brocade.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
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;
as well as URLs for NNTP newsgroup(s).