aboutsummaryrefslogtreecommitdiff
path: root/pc-bios
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2019-04-18 16:53:54 +0200
committerThomas Huth <thuth@redhat.com>2019-05-08 10:52:14 +0200
commitd796588ba13b9d9301433bdf4e461ad5e60d9796 (patch)
tree1c292cc038dbba4a2c3638bf5a55611f9331de52 /pc-bios
parenta6f6d24757a73f7176989134b97284a1a7df11e5 (diff)
downloadqemu-d796588ba13b9d9301433bdf4e461ad5e60d9796.zip
qemu-d796588ba13b9d9301433bdf4e461ad5e60d9796.tar.gz
qemu-d796588ba13b9d9301433bdf4e461ad5e60d9796.tar.bz2
pc-bios/s390-ccw: Clean up harmless misuse of isdigit()
atoui() and get_index() pass char values to isdigit(). With a standard isdigit(), we'd get undefined behavior when the value is negative. Can't happen as char is unsigned on s390x. Even if it ould, we're actually using isdigit() from pc-bios/s390-ccw/libc.h here, which works fine for negative values. Clean up anyway, just to avoid setting a bad example. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20190418145355.21100-6-armbru@redhat.com> [thuth: updated the commit message] Signed-off-by: Thomas Huth <thuth@redhat.com>
Diffstat (limited to 'pc-bios')
-rw-r--r--pc-bios/s390-ccw/libc.c2
-rw-r--r--pc-bios/s390-ccw/menu.c2
2 files changed, 2 insertions, 2 deletions
diff --git a/pc-bios/s390-ccw/libc.c b/pc-bios/s390-ccw/libc.c
index a786566..3187923 100644
--- a/pc-bios/s390-ccw/libc.c
+++ b/pc-bios/s390-ccw/libc.c
@@ -38,7 +38,7 @@ uint64_t atoui(const char *str)
}
while (*str) {
- if (!isdigit(*str)) {
+ if (!isdigit(*(unsigned char *)str)) {
break;
}
val = val * 10 + *str - '0';
diff --git a/pc-bios/s390-ccw/menu.c b/pc-bios/s390-ccw/menu.c
index 82a4ae6..ce3815b 100644
--- a/pc-bios/s390-ccw/menu.c
+++ b/pc-bios/s390-ccw/menu.c
@@ -134,7 +134,7 @@ static int get_index(void)
/* Check for erroneous input */
for (i = 0; i < len; i++) {
- if (!isdigit(buf[i])) {
+ if (!isdigit((unsigned char)buf[i])) {
return -1;
}
}