All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: cohuck@redhat.com, qemu-s390x@nongnu.org
Cc: jjherne@linux.ibm.com, borntraeger@de.ibm.com,
	qemu-devel@nongnu.org, armbru@redhat.com
Subject: [Qemu-devel] [PULL SUBSYSTEM s390x 1/3] pc-bios/s390-ccw: Clean up harmless misuse of isdigit()
Date: Wed,  8 May 2019 11:48:55 +0200	[thread overview]
Message-ID: <20190508094857.21145-2-thuth@redhat.com> (raw)
In-Reply-To: <20190508094857.21145-1-thuth@redhat.com>

From: Markus Armbruster <armbru@redhat.com>

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>
---
 pc-bios/s390-ccw/libc.c | 2 +-
 pc-bios/s390-ccw/menu.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/pc-bios/s390-ccw/libc.c b/pc-bios/s390-ccw/libc.c
index a786566c4c..3187923950 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 82a4ae6315..ce3815b201 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;
         }
     }
-- 
2.21.0



  reply	other threads:[~2019-05-08  9:50 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-08  9:48 [Qemu-devel] [PULL SUBSYSTEM s390x 0/3] s390-ccw-bios: Skip bootmap signature entries Thomas Huth
2019-05-08  9:48 ` Thomas Huth [this message]
2019-05-08  9:48 ` [Qemu-devel] [PULL SUBSYSTEM s390x 2/3] s390-bios: " Thomas Huth
2019-05-10 13:59   ` Christian Borntraeger
2019-05-11  6:15     ` [Qemu-devel] [qemu-s390x] " Thomas Huth
2019-05-13  7:42       ` Cornelia Huck
2019-05-13  7:44         ` Christian Borntraeger
2019-05-13  7:51           ` Cornelia Huck
2019-05-08  9:48 ` [Qemu-devel] [PULL SUBSYSTEM s390x 3/3] pc-bios/s390: Update firmware image with "Skip bootmap signature entries" fix Thomas Huth
2019-05-10 13:55   ` Jason J. Herne
2019-05-10 13:59 ` [Qemu-devel] [PULL SUBSYSTEM s390x 0/3] s390-ccw-bios: Skip bootmap signature entries Christian Borntraeger
2019-05-13 15:05 ` Cornelia Huck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190508094857.21145-2-thuth@redhat.com \
    --to=thuth@redhat.com \
    --cc=armbru@redhat.com \
    --cc=borntraeger@de.ibm.com \
    --cc=cohuck@redhat.com \
    --cc=jjherne@linux.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-s390x@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.