summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmitanand.Chikorde <amitanand.chikorde@kpit.com>2020-07-30 18:48:48 +0530
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2020-09-20 12:48:03 +0200
commit8ca6e3dc71c82f8796674df0fa2699e448dd4999 (patch)
treee92208560b4940d76cd7f2a00557515da292283c
parent2cdfcdf4358a47ff126cc725ca98460d6adde002 (diff)
downloadsystemd-8ca6e3dc71c82f8796674df0fa2699e448dd4999.tar.gz
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. (cherry picked from commit e7e954243a17cceb5278aac6249ee0dcc119b1eb) (cherry picked from commit 1b9c95bfbf7e5fc32e033851bf06f0a9f7f9f08b) (cherry picked from commit 674a2beff0ac7b1cb0358401d6f64d726bca4e4f)
-rw-r--r--src/udev/udevadm-info.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/udev/udevadm-info.c b/src/udev/udevadm-info.c
index 2c8626ffad..7ca1dab75f 100644
--- a/src/udev/udevadm-info.c
+++ b/src/udev/udevadm-info.c
@@ -75,7 +75,7 @@ static void print_all_attributes(sd_device *device, const char *key) {
/* 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;