From e7e954243a17cceb5278aac6249ee0dcc119b1eb Mon Sep 17 00:00:00 2001 From: "Amitanand.Chikorde" Date: Thu, 30 Jul 2020 18:48:48 +0530 Subject: [PATCH] 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. --- src/udev/udevadm-info.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; -- 2.39.2