sacc

sacc (saccomys): simple gopher client.
Log | Files | Refs | LICENSE

commit ed63d85224f39fc733d55b0d326085d7f4bd0b70
parent 2e25654b851d97ab5738a82bd9d47aeb02128be1
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Sat,  8 Sep 2018 12:44:35 +0200

fix undefined behaviours with isdigit() and tolower() functions

Diffstat:
sacc.c | 3++-
ui_txt.c | 4++--
2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/sacc.c b/sacc.c @@ -86,7 +86,8 @@ strcasestr(const char *h, const char *n) return (char *)h; for (; *h; ++h) { - for (i = 0; n[i] && tolower(n[i]) == tolower(h[i]); ++i) + for (i = 0; n[i] && tolower((unsigned char)n[i]) == + tolower((unsigned char)h[i]); ++i) ; if (n[i] == '\0') return (char *)h; diff --git a/ui_txt.c b/ui_txt.c @@ -249,7 +249,7 @@ uiselectitem(Item *entry) putchar('\n'); return NULL; } - if (isdigit(*buf)) { + if (isdigit((unsigned char)*buf)) { cmd = '\0'; nl = '\0'; if (sscanf(buf, "%d%c", &item, &nl) != 2 || nl != '\n') @@ -263,7 +263,7 @@ uiselectitem(Item *entry) *sstr = '\0'; sstr = buf+1; cmd = *buf; - } else if (isdigit(*(buf+1))) { + } else if (isdigit((unsigned char)*(buf+1))) { nl = '\0'; if (sscanf(buf+1, "%d%c", &item, &nl) != 2 || nl != '\n') item = -1;