From e769e3d3bfd5eaccd5a9043b5641bc73550e5528 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Wed, 19 Jul 2017 22:04:37 +0200 Subject: [PATCH] dmsetup: simplify check of parsed cookie value Improving parsing error detection for strtoul. --- tools/dmsetup.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/tools/dmsetup.c b/tools/dmsetup.c index 2eed39e3c..69649ae19 100644 --- a/tools/dmsetup.c +++ b/tools/dmsetup.c @@ -1396,15 +1396,14 @@ static uint32_t _get_cookie_value(const char *str_value) char *p; errno = 0; - if (!(value = strtoul(str_value, &p, 0)) || - *p || - (value == ULONG_MAX && errno == ERANGE) || - value > 0xFFFFFFFF) { + value = strtoul(str_value, &p, 0); + + if (errno || !value || (*p) || (value > UINT32_MAX)) { err("Incorrect cookie value"); return 0; } - else - return (uint32_t) value; + + return (uint32_t) value; } static int _udevflags(CMD_ARGS) -- 2.43.5