Blame SOURCES/0009-libmultipath-set_uint-fix-parsing-for-32bit.patch

96a22b
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
96a22b
From: Martin Wilck <mwilck@suse.com>
96a22b
Date: Tue, 12 May 2020 00:39:27 +0200
96a22b
Subject: [PATCH] libmultipath: set_uint: fix parsing for 32bit
96a22b
96a22b
On architectures where sizeof(long) == sizeof(int), the code wouldn't
96a22b
work as intended. Use strtoul instead. As strtoul happily parses
96a22b
negative numbers as input, require the number to begin with a digit.
96a22b
96a22b
Signed-off-by: Martin Wilck <mwilck@suse.com>
96a22b
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
96a22b
---
96a22b
 libmultipath/dict.c | 11 +++++++----
96a22b
 1 file changed, 7 insertions(+), 4 deletions(-)
96a22b
96a22b
diff --git a/libmultipath/dict.c b/libmultipath/dict.c
96a22b
index 3e25e74f..0e9ea387 100644
96a22b
--- a/libmultipath/dict.c
96a22b
+++ b/libmultipath/dict.c
96a22b
@@ -60,19 +60,22 @@ static int
96a22b
 set_uint(vector strvec, void *ptr)
96a22b
 {
96a22b
 	unsigned int *uint_ptr = (unsigned int *)ptr;
96a22b
-	char *buff, *eptr;
96a22b
-	long res;
96a22b
+	char *buff, *eptr, *p;
96a22b
+	unsigned long res;
96a22b
 	int rc;
96a22b
 
96a22b
 	buff = set_value(strvec);
96a22b
 	if (!buff)
96a22b
 		return 1;
96a22b
 
96a22b
-	res = strtol(buff, &eptr, 10);
96a22b
+	p = buff;
96a22b
+	while (isspace(*p))
96a22b
+		p++;
96a22b
+	res = strtoul(p, &eptr, 10);
96a22b
 	if (eptr > buff)
96a22b
 		while (isspace(*eptr))
96a22b
 			eptr++;
96a22b
-	if (*buff == '\0' || *eptr != '\0' || res < 0 || res > UINT_MAX) {
96a22b
+	if (*buff == '\0' || *eptr != '\0' || !isdigit(*p) || res > UINT_MAX) {
96a22b
 		condlog(1, "%s: invalid value for %s: \"%s\"",
96a22b
 			__func__, (char*)VECTOR_SLOT(strvec, 0), buff);
96a22b
 		rc = 1;
96a22b
-- 
96a22b
2.17.2
96a22b