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