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

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