From 6130e0eeac9db4fa8e6fe5934ec2d0ab202f979e Mon Sep 17 00:00:00 2001 From: Omar Polo Date: Thu, 17 Nov 2022 09:21:38 +0000 Subject: [PATCH] always cast is*() arguments to unsigned char --- gg.c | 4 +++- iri.c | 5 +++-- proxy.c | 6 +++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/gg.c b/gg.c index 35ccc29..e650737 100644 --- a/gg.c +++ b/gg.c @@ -248,7 +248,9 @@ get(const char *r) if (memmem(buf, len, "\r\n", 2) == NULL) errx(1, "invalid reply: no \\r\\n"); - if (!isdigit(buf[0]) || !isdigit(buf[1]) || buf[2] != ' ') + if (!isdigit((unsigned char)buf[0]) || + !isdigit((unsigned char)buf[1]) || + buf[2] != ' ') errx(1, "invalid reply: invalid response format"); code = (buf[0] - '0') * 10 + buf[1] - '0'; diff --git a/iri.c b/iri.c index 8725cdd..c1f9781 100644 --- a/iri.c +++ b/iri.c @@ -51,7 +51,8 @@ valid_pct_enc_string(char *s) if (*s != '%') return 1; - if (!isxdigit(s[1]) || !isxdigit(s[2])) + if (!isxdigit((unsigned char)s[1]) || + !isxdigit((unsigned char)s[2])) return 0; if (s[1] == '0' && s[2] == '0') @@ -153,7 +154,7 @@ parse_port(struct parser *p) p->parsed->port = p->iri; - for (; isdigit(*p->iri); p->iri++) { + for (; isdigit((unsigned char)*p->iri); p->iri++) { i = i * 10 + *p->iri - '0'; if (i > UINT16_MAX) { p->err = "port number too large"; diff --git a/proxy.c b/proxy.c index 3c83a32..0ac83d6 100644 --- a/proxy.c +++ b/proxy.c @@ -160,9 +160,9 @@ proxy_read(struct bufferevent *bev, void *d) } if (len < 3 || len > 1029 || - !isdigit(hdr[0]) || - !isdigit(hdr[1]) || - !isspace(hdr[2])) { + !isdigit((unsigned char)hdr[0]) || + !isdigit((unsigned char)hdr[1]) || + !isspace((unsigned char)hdr[2])) { free(hdr); log_warn(c, "upstream server is trying to send a " "header that's too long.");