Pass unsigned chars to ctype functions.
authorreyk <reyk@openbsd.org>
Tue, 13 Oct 2015 07:57:13 +0000 (07:57 +0000)
committerreyk <reyk@openbsd.org>
Tue, 13 Oct 2015 07:57:13 +0000 (07:57 +0000)
From Michael McConville

usr.sbin/httpd/httpd.c
usr.sbin/httpd/server_http.c

index f6decea..e3e095c 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: httpd.c,v 1.39 2015/08/20 13:00:23 reyk Exp $ */
+/*     $OpenBSD: httpd.c,v 1.40 2015/10/13 07:57:13 reyk Exp $ */
 
 /*
  * Copyright (c) 2014 Reyk Floeter <reyk@openbsd.org>
@@ -565,7 +565,7 @@ canonicalize_host(const char *host, char *name, size_t len)
        for (i = j = 0; i < plen; i++) {
                if (j >= (len - 1))
                        goto fail;
-               c = tolower(host[i]);
+               c = tolower((unsigned char)host[i]);
                if ((c == '.') && (j == 0 || name[j - 1] == '.'))
                        continue;
                name[j++] = c;
@@ -602,7 +602,8 @@ url_decode(char *url)
                switch (*p) {
                case '%':
                        /* Encoding character is followed by two hex chars */
-                       if (!(isxdigit(p[1]) && isxdigit(p[2])))
+                       if (!(isxdigit((unsigned char)p[1]) &&
+                           isxdigit((unsigned char)p[2])))
                                return (NULL);
 
                        hex[0] = p[1];
index f64c892..504f331 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: server_http.c,v 1.99 2015/09/07 14:46:24 reyk Exp $   */
+/*     $OpenBSD: server_http.c,v 1.100 2015/10/13 07:57:13 reyk Exp $  */
 
 /*
  * Copyright (c) 2006 - 2015 Reyk Floeter <reyk@openbsd.org>
@@ -918,7 +918,7 @@ server_expand_http(struct client *clt, const char *val, char *buf,
        /* Find previously matched substrings by index */
        for (p = val; clt->clt_srv_match.sm_nmatch &&
            (p = strstr(p, "%")) != NULL; p++) {
-               if (!isdigit(*(p + 1)))
+               if (!isdigit((unsigned char)*(p + 1)))
                        continue;
 
                /* Copy number, leading '%' char and add trailing \0 */