From: Amitanand.Chikorde Date: Thu, 30 Jul 2020 13:18:48 +0000 (+0530) Subject: udev: fix codesonar warnings X-Git-Tag: v246~3 X-Git-Url: http://git.ipfire.org/?p=thirdparty%2Fsystemd.git;a=commitdiff_plain;h=e7e954243a17cceb5278aac6249ee0dcc119b1eb;hp=b67ec8e5b2e1a74d7e9a3a2b3ac60b7b2e39d4ea udev: fix codesonar warnings Fixed below systemd codesonar warning. isprint() is invoked here with an argument of signed type char, but only has defined behavior for int arguments that are either representable as unsigned char or equal to the value of macro EOF(-1). As per codesonar report, in a number of libc implementations, isprint() function implemented using lookup tables (arrays): passing in a negative value can result in a read underrun. --- diff --git a/src/udev/udevadm-info.c b/src/udev/udevadm-info.c index 7eec84abd5d..ae6d8caf54e 100644 --- a/src/udev/udevadm-info.c +++ b/src/udev/udevadm-info.c @@ -100,7 +100,7 @@ static int print_all_attributes(sd_device *device, bool is_parent) { /* skip nonprintable attributes */ len = strlen(value); - while (len > 0 && isprint(value[len-1])) + while (len > 0 && isprint((unsigned char) value[len-1])) len--; if (len > 0) continue;