Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libc Passing "char" values to ctype(3) functions is prob...
details: https://anonhg.NetBSD.org/src/rev/abd21ca68c52
branches: trunk
changeset: 494498:abd21ca68c52
user: itohy <itohy%NetBSD.org@localhost>
date: Fri Jul 07 08:03:36 2000 +0000
description:
Passing "char" values to ctype(3) functions is problematic.
If an argument of a ctype function is outside "unsigned char"
and if it is not EOF, the behavior is undefined.
The isascii(3) is the sole exception of above and it was used to
be used to check a value was valid for other ctype functions in
ancient systems. On modern systems, the ctype functions take
all values of "unsigned char", and this check is obsolete and
even wrong for non-ASCII systems. However, we leave the isascii()
untouched for now, so as not to change the current behavior.
diffstat:
lib/libc/gen/disklabel.c | 6 +++---
lib/libc/gen/getttyent.c | 8 ++++----
lib/libc/gen/getusershell.c | 7 ++++---
lib/libc/net/base64.c | 10 +++++-----
lib/libc/net/getaddrinfo.c | 6 +++---
lib/libc/net/gethnamaddr.c | 12 ++++++------
lib/libc/net/hesiod.c | 8 ++++----
lib/libc/net/inet_net_pton.c | 21 ++++++++++++---------
lib/libc/net/inet_network.c | 8 ++++----
lib/libc/net/rcmd.c | 7 ++++---
lib/libc/net/res_debug.c | 20 ++++++++++----------
lib/libc/net/res_init.c | 12 ++++++------
lib/libc/net/res_query.c | 11 ++++++-----
lib/libc/regex/regcomp.c | 23 ++++++++++++-----------
lib/libc/time/strptime.c | 12 ++++++------
15 files changed, 89 insertions(+), 82 deletions(-)
diffs (truncated from 682 to 300 lines):
diff -r 8b400dee1736 -r abd21ca68c52 lib/libc/gen/disklabel.c
--- a/lib/libc/gen/disklabel.c Fri Jul 07 05:30:58 2000 +0000
+++ b/lib/libc/gen/disklabel.c Fri Jul 07 08:03:36 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: disklabel.c,v 1.26 2000/01/22 22:19:09 mycroft Exp $ */
+/* $NetBSD: disklabel.c,v 1.27 2000/07/07 08:03:36 itohy Exp $ */
/*
* Copyright (c) 1983, 1987, 1993
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)disklabel.c 8.2 (Berkeley) 5/3/95";
#else
-__RCSID("$NetBSD: disklabel.c,v 1.26 2000/01/22 22:19:09 mycroft Exp $");
+__RCSID("$NetBSD: disklabel.c,v 1.27 2000/07/07 08:03:36 itohy Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -208,7 +208,7 @@
for (nm = names; *nm; nm++)
if (strcasecmp(t, *nm) == 0)
return (nm - names);
- if (isdigit(*t))
+ if (isdigit((unsigned char) *t))
return (atoi(t));
return (0);
}
diff -r 8b400dee1736 -r abd21ca68c52 lib/libc/gen/getttyent.c
--- a/lib/libc/gen/getttyent.c Fri Jul 07 05:30:58 2000 +0000
+++ b/lib/libc/gen/getttyent.c Fri Jul 07 08:03:36 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: getttyent.c,v 1.17 2000/01/22 22:19:11 mycroft Exp $ */
+/* $NetBSD: getttyent.c,v 1.18 2000/07/07 08:03:37 itohy Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)getttyent.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: getttyent.c,v 1.17 2000/01/22 22:19:11 mycroft Exp $");
+__RCSID("$NetBSD: getttyent.c,v 1.18 2000/07/07 08:03:37 itohy Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -98,7 +98,7 @@
;
continue;
}
- while (isspace(*p))
+ while (isspace((unsigned char) *p))
++p;
if (*p && *p != '#')
break;
@@ -119,7 +119,7 @@
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 -r 8b400dee1736 -r abd21ca68c52 lib/libc/gen/getusershell.c
--- a/lib/libc/gen/getusershell.c Fri Jul 07 05:30:58 2000 +0000
+++ b/lib/libc/gen/getusershell.c Fri Jul 07 08:03:36 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: getusershell.c,v 1.20 2000/01/22 22:19:11 mycroft Exp $ */
+/* $NetBSD: getusershell.c,v 1.21 2000/07/07 08:03:37 itohy Exp $ */
/*
* Copyright (c) 1985, 1993
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)getusershell.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: getusershell.c,v 1.20 2000/01/22 22:19:11 mycroft Exp $");
+__RCSID("$NetBSD: getusershell.c,v 1.21 2000/07/07 08:03:37 itohy Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -151,7 +151,8 @@
if (*cp == '#' || *cp == '\0')
continue;
sp = cp;
- while (!isspace(*cp) && *cp != '#' && *cp != '\0')
+ while (!isspace((unsigned char) *cp) && *cp != '#'
+ && *cp != '\0')
cp++;
*cp++ = '\0';
if (sl_add(sl, strdup(sp)) == -1)
diff -r 8b400dee1736 -r abd21ca68c52 lib/libc/net/base64.c
--- a/lib/libc/net/base64.c Fri Jul 07 05:30:58 2000 +0000
+++ b/lib/libc/net/base64.c Fri Jul 07 08:03:36 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: base64.c,v 1.6 1999/09/20 04:39:10 lukem Exp $ */
+/* $NetBSD: base64.c,v 1.7 2000/07/07 08:03:38 itohy Exp $ */
/*
* Copyright (c) 1996 by Internet Software Consortium.
@@ -44,7 +44,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: base64.c,v 1.6 1999/09/20 04:39:10 lukem Exp $");
+__RCSID("$NetBSD: base64.c,v 1.7 2000/07/07 08:03:38 itohy Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@@ -228,7 +228,7 @@
state = 0;
tarindex = 0;
- while ((ch = *src++) != '\0') {
+ while ((ch = (u_char) *src++) != '\0') {
if (isspace(ch)) /* Skip whitespace anywhere. */
continue;
@@ -300,7 +300,7 @@
case 2: /* Valid, means one byte of info */
/* Skip any number of spaces. */
- for (; ch != '\0'; ch = *src++)
+ for (; ch != '\0'; ch = (u_char) *src++)
if (!isspace(ch))
break;
/* Make sure there is another trailing = sign. */
@@ -315,7 +315,7 @@
* We know this char is an =. Is there anything but
* whitespace after it?
*/
- for (; ch != '\0'; ch = *src++)
+ for (; ch != '\0'; ch = (u_char) *src++)
if (!isspace(ch))
return (-1);
diff -r 8b400dee1736 -r abd21ca68c52 lib/libc/net/getaddrinfo.c
--- a/lib/libc/net/getaddrinfo.c Fri Jul 07 05:30:58 2000 +0000
+++ b/lib/libc/net/getaddrinfo.c Fri Jul 07 08:03:36 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: getaddrinfo.c,v 1.43 2000/07/05 12:41:16 itojun Exp $ */
+/* $NetBSD: getaddrinfo.c,v 1.44 2000/07/07 08:03:38 itohy Exp $ */
/* $KAME: getaddrinfo.c,v 1.22 2000/07/05 02:31:36 itojun Exp $ */
/*
@@ -79,7 +79,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: getaddrinfo.c,v 1.43 2000/07/05 12:41:16 itojun Exp $");
+__RCSID("$NetBSD: getaddrinfo.c,v 1.44 2000/07/07 08:03:38 itohy Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
@@ -341,7 +341,7 @@
str_isnumber(p)
const char *p;
{
- const char *q = (const char *)p;
+ const u_char *q = (const u_char *)p;
while (*q) {
if (!isdigit(*q))
return NO;
diff -r 8b400dee1736 -r abd21ca68c52 lib/libc/net/gethnamaddr.c
--- a/lib/libc/net/gethnamaddr.c Fri Jul 07 05:30:58 2000 +0000
+++ b/lib/libc/net/gethnamaddr.c Fri Jul 07 08:03:36 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: gethnamaddr.c,v 1.34 2000/07/06 02:52:07 christos Exp $ */
+/* $NetBSD: gethnamaddr.c,v 1.35 2000/07/07 08:03:38 itohy Exp $ */
/*
* ++Copyright++ 1985, 1988, 1993
@@ -61,7 +61,7 @@
static char sccsid[] = "@(#)gethostnamadr.c 8.1 (Berkeley) 6/4/93";
static char rcsid[] = "Id: gethnamaddr.c,v 8.21 1997/06/01 20:34:37 vixie Exp ";
#else
-__RCSID("$NetBSD: gethnamaddr.c,v 1.34 2000/07/06 02:52:07 christos Exp $");
+__RCSID("$NetBSD: gethnamaddr.c,v 1.35 2000/07/07 08:03:38 itohy Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -591,7 +591,7 @@
* disallow names consisting only of digits/dots, unless
* they end in a dot.
*/
- if (isdigit(name[0]))
+ if (isdigit((u_char) name[0]))
for (cp = name;; ++cp) {
if (!*cp) {
if (*--cp == '.')
@@ -621,10 +621,10 @@
h_errno = NETDB_SUCCESS;
return (&host);
}
- if (!isdigit(*cp) && *cp != '.')
+ if (!isdigit((u_char) *cp) && *cp != '.')
break;
}
- if ((isxdigit(name[0]) && strchr(name, ':') != NULL) ||
+ if ((isxdigit((u_char) name[0]) && strchr(name, ':') != NULL) ||
name[0] == ':')
for (cp = name;; ++cp) {
if (!*cp) {
@@ -653,7 +653,7 @@
h_errno = NETDB_SUCCESS;
return (&host);
}
- if (!isxdigit(*cp) && *cp != ':' && *cp != '.')
+ if (!isxdigit((u_char) *cp) && *cp != ':' && *cp != '.')
break;
}
diff -r 8b400dee1736 -r abd21ca68c52 lib/libc/net/hesiod.c
--- a/lib/libc/net/hesiod.c Fri Jul 07 05:30:58 2000 +0000
+++ b/lib/libc/net/hesiod.c Fri Jul 07 08:03:36 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hesiod.c,v 1.13 2000/06/18 04:07:03 ghudson Exp $ */
+/* $NetBSD: hesiod.c,v 1.14 2000/07/07 08:03:39 itohy Exp $ */
/* Copyright (c) 1996 by Internet Software Consortium.
*
@@ -52,7 +52,7 @@
"#Id: hesiod_p.h,v 1.1 1996/12/08 21:39:37 ghudson Exp #");
__IDSTRING(rcsid_hescompat_c,
"#Id: hescompat.c,v 1.1.2.1 1996/12/16 08:37:45 ghudson Exp #");
-__RCSID("$NetBSD: hesiod.c,v 1.13 2000/06/18 04:07:03 ghudson Exp $");
+__RCSID("$NetBSD: hesiod.c,v 1.14 2000/07/07 08:03:39 itohy Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
@@ -341,10 +341,10 @@
p++;
*p++ = 0;
- while (isspace(*p) || *p == '=')
+ while (isspace((u_char) *p) || *p == '=')
p++;
data = p;
- while (!isspace(*p))
+ while (!isspace((u_char) *p))
p++;
*p = 0;
diff -r 8b400dee1736 -r abd21ca68c52 lib/libc/net/inet_net_pton.c
--- a/lib/libc/net/inet_net_pton.c Fri Jul 07 05:30:58 2000 +0000
+++ b/lib/libc/net/inet_net_pton.c Fri Jul 07 08:03:36 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: inet_net_pton.c,v 1.13 2000/07/06 02:56:55 christos Exp $ */
+/* $NetBSD: inet_net_pton.c,v 1.14 2000/07/07 08:03:39 itohy Exp $ */
/*
* Copyright (c) 1996,1999 by Internet Software Consortium.
@@ -22,7 +22,7 @@
#if 0
static const char rcsid[] = "Id: inet_net_pton.c,v 8.3 1996/11/11 06:36:52 vixie Exp ";
#else
-__RCSID("$NetBSD: inet_net_pton.c,v 1.13 2000/07/06 02:56:55 christos Exp $");
+__RCSID("$NetBSD: inet_net_pton.c,v 1.14 2000/07/07 08:03:39 itohy Exp $");
#endif
#endif
@@ -116,16 +116,17 @@
_DIAGASSERT(src != NULL);
_DIAGASSERT(dst != NULL);
- ch = *src++;
+ ch = (u_char) *src++;
if (ch == '0' && (src[0] == 'x' || src[0] == 'X')
- && isascii(src[1]) && isxdigit(src[1])) {
+ && isascii(src[1]) && isxdigit((u_char) src[1])) {
/* Hexadecimal: Eat nybble string. */
/* size is unsigned */
if (size == 0)
goto emsgsize;
dirty = 0;
src++; /* skip x or X. */
- while ((ch = *src++) != '\0' && isascii(ch) && isxdigit(ch)) {
+ while ((ch = (u_char) *src++) != '\0' && isascii(ch)
+ && isxdigit(ch)) {
if (isupper(ch))
ch = tolower(ch);
n = strchr(xdigits, ch) - xdigits;
@@ -153,7 +154,7 @@
tmp += n;
if (tmp > 255)
goto enoent;
- } while ((ch = *src++) != '\0' &&
+ } while ((ch = (u_char) *src++) != '\0' &&
isascii(ch) && isdigit(ch));
if (size-- == 0)
goto emsgsize;
@@ -170,16 +171,18 @@
goto enoent;
bits = -1;
- if (ch == '/' && isascii(src[0]) && isdigit(src[0]) && dst > odst) {
+ if (ch == '/' && isascii(src[0]) && isdigit((u_char) src[0])
+ && dst > odst) {
/* CIDR width specifier. Nothing can follow it. */
- ch = *src++; /* Skip over the /. */
Home |
Main Index |
Thread Index |
Old Index