summaryrefslogtreecommitdiffstats
path: root/lib/libc
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>2013-11-24 23:51:28 +0000
committerderaadt <deraadt@openbsd.org>2013-11-24 23:51:28 +0000
commitdfe5467e3c6b93ccc8be21818dca4babdc79fd90 (patch)
tree38c9171a2ed326bfcda1e4e5c4dd927317ae17a4 /lib/libc
parentIncrease NMBCLUSTERS a bit. Riding upon the kernel memory saved by the pmap (diff)
downloadwireguard-openbsd-dfe5467e3c6b93ccc8be21818dca4babdc79fd90.tar.xz
wireguard-openbsd-dfe5467e3c6b93ccc8be21818dca4babdc79fd90.zip
most obvious unsigned char casts for ctype
ok jca krw ingo
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/asr/asr_utils.c4
-rw-r--r--lib/libc/asr/gethostnamadr_async.c5
-rw-r--r--lib/libc/gen/auth_subr.c36
-rw-r--r--lib/libc/gen/authenticate.c4
-rw-r--r--lib/libc/gen/fnmatch.c25
-rw-r--r--lib/libc/gen/getttyent.c7
-rw-r--r--lib/libc/gen/getusershell.c4
-rw-r--r--lib/libc/gen/readpassphrase.c8
-rw-r--r--lib/libc/gen/setmode.c4
-rw-r--r--lib/libc/net/base64.c14
-rw-r--r--lib/libc/net/ethers.c10
-rw-r--r--lib/libc/net/inet_addr.c16
-rw-r--r--lib/libc/net/ruserok.c7
-rw-r--r--lib/libc/time/zic.c6
14 files changed, 85 insertions, 65 deletions
diff --git a/lib/libc/asr/asr_utils.c b/lib/libc/asr/asr_utils.c
index f5a1da8a528..20b10c58fa8 100644
--- a/lib/libc/asr/asr_utils.c
+++ b/lib/libc/asr/asr_utils.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: asr_utils.c,v 1.8 2013/07/12 14:36:21 eric Exp $ */
+/* $OpenBSD: asr_utils.c,v 1.9 2013/11/24 23:51:29 deraadt Exp $ */
/*
* Copyright (c) 2009-2012 Eric Faurot <eric@faurot.net>
*
@@ -55,7 +55,7 @@ dname_check_label(const char *s, size_t l)
return (-1);
for (l--; l; l--, s++)
- if (!(isalnum(*s) || *s == '_' || *s == '-'))
+ if (!(isalnum((unsigned char)*s) || *s == '_' || *s == '-'))
return (-1);
return (0);
diff --git a/lib/libc/asr/gethostnamadr_async.c b/lib/libc/asr/gethostnamadr_async.c
index 900370791c1..41bd558c760 100644
--- a/lib/libc/asr/gethostnamadr_async.c
+++ b/lib/libc/asr/gethostnamadr_async.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: gethostnamadr_async.c,v 1.22 2013/07/17 07:43:23 eric Exp $ */
+/* $OpenBSD: gethostnamadr_async.c,v 1.23 2013/11/24 23:51:29 deraadt Exp $ */
/*
* Copyright (c) 2012 Eric Faurot <eric@openbsd.org>
*
@@ -174,7 +174,8 @@ gethostnamadr_async_run(struct async *as, struct async_res *ar)
/* Name might be an IP address string */
if (as->as_type == ASR_GETHOSTBYNAME) {
for (c = as->as.hostnamadr.name; *c; c++)
- if (!isdigit(*c) && *c != '.' && *c != ':')
+ if (!isdigit((unsigned char)*c) &&
+ *c != '.' && *c != ':')
break;
if (*c == 0 &&
inet_pton(as->as.hostnamadr.family,
diff --git a/lib/libc/gen/auth_subr.c b/lib/libc/gen/auth_subr.c
index e4b7f0eb09f..5b385fbb6c7 100644
--- a/lib/libc/gen/auth_subr.c
+++ b/lib/libc/gen/auth_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: auth_subr.c,v 1.38 2013/09/30 12:02:32 millert Exp $ */
+/* $OpenBSD: auth_subr.c,v 1.39 2013/11/24 23:51:29 deraadt Exp $ */
/*
* Copyright (c) 2000-2002,2004 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -346,18 +346,20 @@ auth_setenv(auth_session_t *as)
*/
for (line = as->spool; line < as->spool + as->index;) {
if (!strncasecmp(line, BI_SETENV, sizeof(BI_SETENV)-1)) {
- if (isblank(line[sizeof(BI_SETENV) - 1])) {
+ if (isblank((unsigned char)line[sizeof(BI_SETENV) - 1])) {
/* only do it once! */
line[0] = 'd'; line[1] = 'i'; line[2] = 'd';
line += sizeof(BI_SETENV) - 1;
- for (name = line; isblank(*name); ++name)
+ for (name = line;
+ isblank((unsigned char)*name); ++name)
;
- for (line = name; *line && !isblank(*line);
+ for (line = name;
+ *line && !isblank((unsigned char)*line);
++line)
;
if (*line)
*line++ = '\0';
- for (; isblank(*line); ++line)
+ for (; isblank((unsigned char)*line); ++line)
;
if (*line != '\0' && setenv(name, line, 1))
_warn("setenv(%s, %s)", name, line);
@@ -368,9 +370,11 @@ auth_setenv(auth_session_t *as)
/* only do it once! */
line[2] = 'd'; line[3] = 'i'; line[4] = 'd';
line += sizeof(BI_UNSETENV) - 1;
- for (name = line; isblank(*name); ++name)
+ for (name = line;
+ isblank((unsigned char)*name); ++name)
;
- for (line = name; *line && !isblank(*line);
+ for (line = name;
+ *line && !isblank((unsigned char)*line);
++line)
;
if (*line)
@@ -391,14 +395,14 @@ auth_clrenv(auth_session_t *as)
{
char *line;
- for (line = as->spool; line < as->spool + as->index;) {
+ for (line = as->spool; line < as->spool + as->index;) {
if (!strncasecmp(line, BI_SETENV, sizeof(BI_SETENV)-1)) {
- if (isblank(line[sizeof(BI_SETENV) - 1])) {
+ if (isblank((unsigned char)line[sizeof(BI_SETENV) - 1])) {
line[0] = 'i'; line[1] = 'g'; line[2] = 'n';
}
} else
if (!strncasecmp(line, BI_UNSETENV, sizeof(BI_UNSETENV)-1)) {
- if (isblank(line[sizeof(BI_UNSETENV) - 1])) {
+ if (isblank((unsigned char)line[sizeof(BI_UNSETENV) - 1])) {
line[2] = 'i'; line[3] = 'g'; line[4] = 'n';
}
}
@@ -661,17 +665,17 @@ auth_getvalue(auth_session_t *as, char *what)
goto next;
line += sizeof(BI_VALUE) - 1;
- if (!isblank(*line))
+ if (!isblank((unsigned char)*line))
goto next;
- while (isblank(*++line))
+ while (isblank((unsigned char)*++line))
;
if (strncmp(line, what, len) != 0 ||
- !isblank(line[len]))
+ !isblank((unsigned char)line[len]))
goto next;
line += len;
- while (isblank(*++line))
+ while (isblank((unsigned char)*++line))
;
value = strdup(line);
if (value == NULL)
@@ -697,12 +701,12 @@ auth_getvalue(auth_session_t *as, char *what)
case '3': case '4': case '5':
case '6': case '7':
n = *line - '0';
- if (isdigit(line[1])) {
+ if (isdigit((unsigned char)line[1])) {
++line;
n <<= 3;
n |= *line-'0';
}
- if (isdigit(line[1])) {
+ if (isdigit((unsigned char)line[1])) {
++line;
n <<= 3;
n |= *line-'0';
diff --git a/lib/libc/gen/authenticate.c b/lib/libc/gen/authenticate.c
index 13ed2e33292..0c2d95369d8 100644
--- a/lib/libc/gen/authenticate.c
+++ b/lib/libc/gen/authenticate.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: authenticate.c,v 1.19 2013/09/30 12:02:32 millert Exp $ */
+/* $OpenBSD: authenticate.c,v 1.20 2013/11/24 23:51:29 deraadt Exp $ */
/*-
* Copyright (c) 1997 Berkeley Software Design, Inc. All rights reserved.
@@ -87,7 +87,7 @@ auth_mkvalue(char *value)
*p++ = *value;
break;
default:
- if (!isprint(*value)) {
+ if (!isprint((unsigned char)*value)) {
*p++ = '\\';
*p++ = ((*value >> 6) & 0x3) + '0';
*p++ = ((*value >> 3) & 0x7) + '0';
diff --git a/lib/libc/gen/fnmatch.c b/lib/libc/gen/fnmatch.c
index c3d1a3ccf5e..2c860f7ebf8 100644
--- a/lib/libc/gen/fnmatch.c
+++ b/lib/libc/gen/fnmatch.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fnmatch.c,v 1.16 2011/12/06 11:47:46 stsp Exp $ */
+/* $OpenBSD: fnmatch.c,v 1.17 2013/11/24 23:51:29 deraadt Exp $ */
/* Copyright (c) 2011, VMware, Inc.
* All rights reserved.
@@ -214,10 +214,13 @@ leadingclosebrace:
/* XXX: handle locale/MBCS comparison, advance by MBCS char width */
if ((**string >= *startch) && (**string <= **pattern))
result = 0;
- else if (nocase && (isupper(**string) || isupper(*startch)
- || isupper(**pattern))
- && (tolower(**string) >= tolower(*startch))
- && (tolower(**string) <= tolower(**pattern)))
+ else if (nocase && (isupper((unsigned char)**string) ||
+ isupper((unsigned char)*startch) ||
+ isupper((unsigned char)**pattern))
+ && (tolower((unsigned char)**string) >=
+ tolower((unsigned char)*startch))
+ && (tolower((unsigned char)**string) <=
+ tolower((unsigned char)**pattern)))
result = 0;
++*pattern;
@@ -227,8 +230,10 @@ leadingclosebrace:
/* XXX: handle locale/MBCS comparison, advance by MBCS char width */
if ((**string == **pattern))
result = 0;
- else if (nocase && (isupper(**string) || isupper(**pattern))
- && (tolower(**string) == tolower(**pattern)))
+ else if (nocase && (isupper((unsigned char)**string) ||
+ isupper((unsigned char)**pattern))
+ && (tolower((unsigned char)**string) ==
+ tolower((unsigned char)**pattern)))
result = 0;
++*pattern;
@@ -254,8 +259,10 @@ leadingclosebrace:
/* XXX: handle locale/MBCS comparison, advance by the MBCS char width */
if (**string == **pattern)
result = 0;
- else if (nocase && (isupper(**string) || isupper(**pattern))
- && (tolower(**string) == tolower(**pattern)))
+ else if (nocase && (isupper((unsigned char)**string) ||
+ isupper((unsigned char)**pattern))
+ && (tolower((unsigned char)**string) ==
+ tolower((unsigned char)**pattern)))
result = 0;
/* Refuse to advance over trailing slash or nulls
diff --git a/lib/libc/gen/getttyent.c b/lib/libc/gen/getttyent.c
index f0ab5ab0d97..c95cb9e574b 100644
--- a/lib/libc/gen/getttyent.c
+++ b/lib/libc/gen/getttyent.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: getttyent.c,v 1.12 2009/11/09 00:18:27 kurt Exp $ */
+/* $OpenBSD: getttyent.c,v 1.13 2013/11/24 23:51:29 deraadt Exp $ */
/*
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
@@ -72,7 +72,7 @@ getttyent(void)
;
continue;
}
- while (isspace(*p))
+ while (isspace((unsigned char)*p))
++p;
if (*p && *p != '#')
break;
@@ -93,7 +93,8 @@ getttyent(void)
tty.ty_status = 0;
tty.ty_window = NULL;
-#define scmp(e) !strncmp(p, e, sizeof(e) - 1) && isspace(p[sizeof(e) - 1])
+#define scmp(e) !strncmp(p, e, sizeof(e) - 1) && \
+ isspace((unsigned char)p[sizeof(e) - 1])
#define vcmp(e) !strncmp(p, e, sizeof(e) - 1) && p[sizeof(e) - 1] == '='
for (; *p; p = skip(p)) {
if (scmp(_TTYS_OFF))
diff --git a/lib/libc/gen/getusershell.c b/lib/libc/gen/getusershell.c
index f2520151afc..a46fd02571f 100644
--- a/lib/libc/gen/getusershell.c
+++ b/lib/libc/gen/getusershell.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: getusershell.c,v 1.10 2013/09/30 12:02:34 millert Exp $ */
+/* $OpenBSD: getusershell.c,v 1.11 2013/11/24 23:51:29 deraadt Exp $ */
/*
* Copyright (c) 1985, 1993
* The Regents of the University of California. All rights reserved.
@@ -124,7 +124,7 @@ initshells(void)
if (*cp == '#' || *cp == '\0')
continue;
*sp++ = cp;
- while (!isspace(*cp) && *cp != '#' && *cp != '\0')
+ while (!isspace((unsigned char)*cp) && *cp != '#' && *cp != '\0')
cp++;
*cp++ = '\0';
}
diff --git a/lib/libc/gen/readpassphrase.c b/lib/libc/gen/readpassphrase.c
index b7f87c9dabc..6854617591c 100644
--- a/lib/libc/gen/readpassphrase.c
+++ b/lib/libc/gen/readpassphrase.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: readpassphrase.c,v 1.23 2010/05/14 13:30:34 millert Exp $ */
+/* $OpenBSD: readpassphrase.c,v 1.24 2013/11/24 23:51:29 deraadt Exp $ */
/*
* Copyright (c) 2000-2002, 2007, 2010
@@ -117,11 +117,11 @@ restart:
if (p < end) {
if ((flags & RPP_SEVENBIT))
ch &= 0x7f;
- if (isalpha(ch)) {
+ if (isalpha((unsigned char)ch)) {
if ((flags & RPP_FORCELOWER))
- ch = (char)tolower(ch);
+ ch = (char)tolower((unsigned char)ch);
if ((flags & RPP_FORCEUPPER))
- ch = (char)toupper(ch);
+ ch = (char)toupper((unsigned char)ch);
}
*p++ = ch;
}
diff --git a/lib/libc/gen/setmode.c b/lib/libc/gen/setmode.c
index 9cc2cbc59ba..3231d065ad5 100644
--- a/lib/libc/gen/setmode.c
+++ b/lib/libc/gen/setmode.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: setmode.c,v 1.20 2007/09/02 15:19:16 deraadt Exp $ */
+/* $OpenBSD: setmode.c,v 1.21 2013/11/24 23:51:29 deraadt Exp $ */
/* $NetBSD: setmode.c,v 1.15 1997/02/07 22:21:06 christos Exp $ */
/*
@@ -196,7 +196,7 @@ setmode(const char *p)
* If an absolute number, get it and return; disallow non-octal digits
* or illegal bits.
*/
- if (isdigit(*p)) {
+ if (isdigit((unsigned char)*p)) {
perml = strtoul(p, &ep, 8);
/* The test on perml will also catch overflow. */
if (*ep != '\0' || (perml & ~(STANDARD_BITS|S_ISTXT))) {
diff --git a/lib/libc/net/base64.c b/lib/libc/net/base64.c
index d432c48d5c9..78ef449a753 100644
--- a/lib/libc/net/base64.c
+++ b/lib/libc/net/base64.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: base64.c,v 1.5 2006/10/21 09:55:03 otto Exp $ */
+/* $OpenBSD: base64.c,v 1.6 2013/11/24 23:51:28 deraadt Exp $ */
/*
* Copyright (c) 1996 by Internet Software Consortium.
@@ -199,7 +199,7 @@ b64_pton(src, target, targsize)
state = 0;
tarindex = 0;
- while ((ch = *src++) != '\0') {
+ while ((ch = (unsigned char)*src++) != '\0') {
if (isspace(ch)) /* Skip whitespace anywhere. */
continue;
@@ -258,8 +258,8 @@ b64_pton(src, target, targsize)
* on a byte boundary, and/or with erroneous trailing characters.
*/
- if (ch == Pad64) { /* We got a pad char. */
- ch = *src++; /* Skip it, get next. */
+ if (ch == Pad64) { /* We got a pad char. */
+ ch = (unsigned char)*src++; /* Skip it, get next. */
switch (state) {
case 0: /* Invalid = in first position */
case 1: /* Invalid = in second position */
@@ -267,13 +267,13 @@ b64_pton(src, target, targsize)
case 2: /* Valid, means one byte of info */
/* Skip any number of spaces. */
- for (; ch != '\0'; ch = *src++)
+ for (; ch != '\0'; ch = (unsigned char)*src++)
if (!isspace(ch))
break;
/* Make sure there is another trailing = sign. */
if (ch != Pad64)
return (-1);
- ch = *src++; /* Skip the = */
+ ch = (unsigned char)*src++; /* Skip the = */
/* Fall through to "single trailing =" case. */
/* FALLTHROUGH */
@@ -282,7 +282,7 @@ b64_pton(src, target, targsize)
* We know this char is an =. Is there anything but
* whitespace after it?
*/
- for (; ch != '\0'; ch = *src++)
+ for (; ch != '\0'; ch = (unsigned char)*src++)
if (!isspace(ch))
return (-1);
diff --git a/lib/libc/net/ethers.c b/lib/libc/net/ethers.c
index d4243ff1dac..af31bb8e607 100644
--- a/lib/libc/net/ethers.c
+++ b/lib/libc/net/ethers.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ethers.c,v 1.20 2005/08/06 20:30:03 espie Exp $ */
+/* $OpenBSD: ethers.c,v 1.21 2013/11/24 23:51:28 deraadt Exp $ */
/*
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -64,7 +64,7 @@ _ether_aton(const char *s, struct ether_addr *e)
long l;
char *pp;
- while (isspace(*s))
+ while (isspace((unsigned char)*s))
s++;
/* expect 6 hex octets separated by ':' or space/NUL if last octet */
@@ -72,7 +72,9 @@ _ether_aton(const char *s, struct ether_addr *e)
l = strtol(s, &pp, 16);
if (pp == s || l > 0xFF || l < 0)
return (NULL);
- if (!(*pp == ':' || (i == 5 && (isspace(*pp) || *pp == '\0'))))
+ if (!(*pp == ':' ||
+ (i == 5 && (isspace((unsigned char)*pp) ||
+ *pp == '\0'))))
return (NULL);
e->ether_addr_octet[i] = (u_char)l;
s = pp + 1;
@@ -216,7 +218,7 @@ ether_line(const char *line, struct ether_addr *e, char *hostname)
goto bad;
/* Now get the hostname */
- while (isspace(*p))
+ while (isspace((unsigned char)*p))
p++;
if (*p == '\0')
goto bad;
diff --git a/lib/libc/net/inet_addr.c b/lib/libc/net/inet_addr.c
index c962a03382d..18762ab5223 100644
--- a/lib/libc/net/inet_addr.c
+++ b/lib/libc/net/inet_addr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: inet_addr.c,v 1.9 2005/08/06 20:30:03 espie Exp $ */
+/* $OpenBSD: inet_addr.c,v 1.10 2013/11/24 23:51:28 deraadt Exp $ */
/*
* ++Copyright++ 1983, 1990, 1993
@@ -94,7 +94,7 @@ inet_aton(const char *cp, struct in_addr *addr)
* Values are specified as for C:
* 0x=hex, 0=octal, isdigit=decimal.
*/
- if (!isdigit(c))
+ if (!isdigit((unsigned char)c))
return (0);
val = 0; base = 10;
if (c == '0') {
@@ -105,12 +105,15 @@ inet_aton(const char *cp, struct in_addr *addr)
base = 8;
}
for (;;) {
- if (isascii(c) && isdigit(c)) {
+ if (isascii((unsigned char)c) &&
+ isdigit((unsigned char)c)) {
val = (val * base) + (c - '0');
c = *++cp;
- } else if (base == 16 && isascii(c) && isxdigit(c)) {
+ } else if (base == 16 &&
+ isascii((unsigned char)c) &&
+ isxdigit((unsigned char)c)) {
val = (val << 4) |
- (c + 10 - (islower(c) ? 'a' : 'A'));
+ (c + 10 - (islower((unsigned char)c) ? 'a' : 'A'));
c = *++cp;
} else
break;
@@ -132,7 +135,8 @@ inet_aton(const char *cp, struct in_addr *addr)
/*
* Check for trailing characters.
*/
- if (c != '\0' && (!isascii(c) || !isspace(c)))
+ if (c != '\0' &&
+ (!isascii((unsigned char)c) || !isspace((unsigned char)c)))
return (0);
/*
* Concoct the address according to
diff --git a/lib/libc/net/ruserok.c b/lib/libc/net/ruserok.c
index 46fba4beb26..21646c156ba 100644
--- a/lib/libc/net/ruserok.c
+++ b/lib/libc/net/ruserok.c
@@ -214,9 +214,10 @@ __ivaliduser_sa(FILE *hostf, struct sockaddr *raddr, socklen_t salen,
if (*p == '#')
continue;
while (p < buf + buflen && *p != '\n' && *p != ' ' && *p != '\t') {
- if (!isprint(*p))
+ if (!isprint((unsigned char)*p))
goto bail;
- *p = isupper(*p) ? tolower(*p) : *p;
+ *p = isupper((unsigned char)*p) ?
+ tolower((unsigned char)*p) : *p;
p++;
}
if (p >= buf + buflen)
@@ -230,7 +231,7 @@ __ivaliduser_sa(FILE *hostf, struct sockaddr *raddr, socklen_t salen,
user = p;
while (p < buf + buflen && *p != '\n' && *p != ' ' &&
*p != '\t') {
- if (!isprint(*p))
+ if (!isprint((unsigned char)*p))
goto bail;
p++;
}
diff --git a/lib/libc/time/zic.c b/lib/libc/time/zic.c
index 304711129c0..07187ec72e2 100644
--- a/lib/libc/time/zic.c
+++ b/lib/libc/time/zic.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: zic.c,v 1.34 2011/04/25 13:27:27 millert Exp $ */
+/* $OpenBSD: zic.c,v 1.35 2013/11/24 23:51:29 deraadt Exp $ */
/*
** This file is in the public domain, so clarified as of
** 2006-07-17 by Arthur David Olson.
@@ -2520,8 +2520,8 @@ register char * cp;
exit(1);
}
} while (*cp != '\0' && *cp != '#' &&
- (!isascii(*cp) || !isspace((unsigned char) *cp)));
- if (isascii(*cp) && isspace((unsigned char) *cp))
+ (!isascii((unsigned char)*cp) || !isspace((unsigned char) *cp)));
+ if (isascii((unsigned char) *cp) && isspace((unsigned char) *cp))
++cp;
*dp = '\0';
}