naccyde / rpms / iproute

Forked from rpms/iproute 5 months ago
Clone

Blame SOURCES/0177-utils-fix-hex-digits-parsing-in-hexstring_a2n.patch

049c96
From 91c9a1f1f26b1800e1d1d1cd7d814d3e2d14f822 Mon Sep 17 00:00:00 2001
049c96
From: Davide Caratti <dcaratti@redhat.com>
049c96
Date: Wed, 6 Jul 2016 18:41:37 +0200
049c96
Subject: [PATCH] utils: fix hex digits parsing in hexstring_a2n()
049c96
049c96
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1300765
049c96
Upstream Status: iproute2.git commit 9ba4126dc4d6
049c96
049c96
commit 9ba4126dc4d6abb8dc5c8c8d52177849e764a14e
049c96
Author: Beniamino Galvani <bgalvani@redhat.com>
049c96
Date:   Tue Jun 14 22:55:17 2016 +0200
049c96
049c96
    utils: fix hex digits parsing in hexstring_a2n()
049c96
049c96
    strtoul() only modifies errno on overflow, so if errno is not zero
049c96
    before calling the function its value is preserved and makes the
049c96
    function fail for valid inputs; initialize it.
049c96
049c96
    Signed-off-by: Beniamino Galvani <bgalvani@redhat.com>
049c96
049c96
Signed-off-by: Davide Caratti <dcaratti@redhat.com>
049c96
---
049c96
 lib/utils.c | 1 +
049c96
 1 file changed, 1 insertion(+)
049c96
049c96
diff --git a/lib/utils.c b/lib/utils.c
049c96
index dedadff..b310166 100644
049c96
--- a/lib/utils.c
049c96
+++ b/lib/utils.c
049c96
@@ -834,6 +834,7 @@ __u8 *hexstring_a2n(const char *str, __u8 *buf, int blen, unsigned int *len)
049c96
 
049c96
 		strncpy(tmpstr, str, 2);
049c96
 		tmpstr[2] = '\0';
049c96
+		errno = 0;
049c96
 		tmp = strtoul(tmpstr, &endptr, 16);
049c96
 		if (errno != 0 || tmp > 0xFF || *endptr != '\0')
049c96
 			return NULL;
049c96
-- 
049c96
1.8.3.1
049c96