]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udev: fix codesonar warnings
authorAmitanand.Chikorde <amitanand.chikorde@kpit.com>
Thu, 30 Jul 2020 13:18:48 +0000 (18:48 +0530)
committerLennart Poettering <lennart@poettering.net>
Thu, 30 Jul 2020 16:55:50 +0000 (18:55 +0200)
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.

src/udev/udevadm-info.c

index 7eec84abd5d8e2485f36a8e0a7e7ccc157af8cf1..ae6d8caf54e02c39c4b5f4245b5523cc9713eb97 100644 (file)
@@ -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;