device-mapper-multipath/0016-libmultipath-set_uint-fix-parsing-for-32bit.patch
Benjamin Marzinski 2b0cd7cceb device-mapper-multipath-0.8.4-2
Rebased on top of Martin Wilck's queue of ACKed upstream commits
  * https://github.com/openSUSE/multipath-tools/tree/upstream-queue
  * All previous patches have been reordered, with the exception of
    0011-libdmmp-Add-support-for-upcoming-json-c-0.14.0.patch
    which has been replaced with
    0029-fix-boolean-value-with-json-c-0.14.patch
Modify 0054-RH-add-mpathconf.patch
  * remove default enable_foreign and property blacklist_exceptions
    settings, and deal with the builtin default change from
    0031-libmultipath-set-enable_foreign-to-NONE-by-default.patch.
    Fixes bz #1853668
Add 0048-Makefile.inc-trim-extra-information-from-systemd-ver.patch
Add 0049-kpartx-fix-Wsign-compare-error.patch
  * The above two patches have been submitted upstream
2020-07-08 23:16:57 -05:00

49 lines
1.4 KiB
Diff

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