diff options
author | deraadt <> | 2013-11-25 18:23:51 +0000 |
---|---|---|
committer | deraadt <> | 2013-11-25 18:23:51 +0000 |
commit | cf65182f8b05e806af310a6d2fa559e46e674e56 (patch) | |
tree | 26f90a1f79e12812e601e7217c2f8ad5ae4e5f96 /src/lib/libc/net/inet_net_pton.c | |
parent | a464b5bba9311ea2be00c98fd0338fed1728fc32 (diff) | |
download | openbsd-cf65182f8b05e806af310a6d2fa559e46e674e56.tar.gz openbsd-cf65182f8b05e806af310a6d2fa559e46e674e56.tar.bz2 openbsd-cf65182f8b05e806af310a6d2fa559e46e674e56.zip |
unsigned char changes for ctype
re-re-reviewed by krw
Diffstat (limited to 'src/lib/libc/net/inet_net_pton.c')
-rw-r--r-- | src/lib/libc/net/inet_net_pton.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/lib/libc/net/inet_net_pton.c b/src/lib/libc/net/inet_net_pton.c index 74261399f7..1683a79043 100644 --- a/src/lib/libc/net/inet_net_pton.c +++ b/src/lib/libc/net/inet_net_pton.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: inet_net_pton.c,v 1.7 2012/06/22 19:13:37 gilles Exp $ */ | 1 | /* $OpenBSD: inet_net_pton.c,v 1.8 2013/11/25 18:23:51 deraadt Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * Copyright (c) 2012 by Gilles Chehade <gilles@openbsd.org> | 4 | * Copyright (c) 2012 by Gilles Chehade <gilles@openbsd.org> |
@@ -85,16 +85,16 @@ inet_net_pton_ipv4(const char *src, u_char *dst, size_t size) | |||
85 | int n, ch, tmp, dirty, bits; | 85 | int n, ch, tmp, dirty, bits; |
86 | const u_char *odst = dst; | 86 | const u_char *odst = dst; |
87 | 87 | ||
88 | ch = *src++; | 88 | ch = (unsigned char)*src++; |
89 | if (ch == '0' && (src[0] == 'x' || src[0] == 'X') | 89 | if (ch == '0' && (src[0] == 'x' || src[0] == 'X') |
90 | && isascii(src[1]) && isxdigit(src[1])) { | 90 | && isascii((unsigned char)src[1]) && isxdigit((unsigned char)src[1])) { |
91 | /* Hexadecimal: Eat nybble string. */ | 91 | /* Hexadecimal: Eat nybble string. */ |
92 | if (size <= 0) | 92 | if (size <= 0) |
93 | goto emsgsize; | 93 | goto emsgsize; |
94 | *dst = 0, dirty = 0; | 94 | *dst = 0, dirty = 0; |
95 | src++; /* skip x or X. */ | 95 | src++; /* skip x or X. */ |
96 | while ((ch = *src++) != '\0' && | 96 | while ((ch = (unsigned char)*src++) != '\0' && |
97 | isascii(ch) && isxdigit(ch)) { | 97 | isascii(ch) && isxdigit(ch)) { |
98 | if (isupper(ch)) | 98 | if (isupper(ch)) |
99 | ch = tolower(ch); | 99 | ch = tolower(ch); |
100 | n = strchr(xdigits, ch) - xdigits; | 100 | n = strchr(xdigits, ch) - xdigits; |
@@ -120,7 +120,7 @@ inet_net_pton_ipv4(const char *src, u_char *dst, size_t size) | |||
120 | tmp += n; | 120 | tmp += n; |
121 | if (tmp > 255) | 121 | if (tmp > 255) |
122 | goto enoent; | 122 | goto enoent; |
123 | } while ((ch = *src++) != '\0' && | 123 | } while ((ch = (unsigned char)*src++) != '\0' && |
124 | isascii(ch) && isdigit(ch)); | 124 | isascii(ch) && isdigit(ch)); |
125 | if (size-- <= 0) | 125 | if (size-- <= 0) |
126 | goto emsgsize; | 126 | goto emsgsize; |
@@ -129,7 +129,7 @@ inet_net_pton_ipv4(const char *src, u_char *dst, size_t size) | |||
129 | break; | 129 | break; |
130 | if (ch != '.') | 130 | if (ch != '.') |
131 | goto enoent; | 131 | goto enoent; |
132 | ch = *src++; | 132 | ch = (unsigned char)*src++; |
133 | if (!isascii(ch) || !isdigit(ch)) | 133 | if (!isascii(ch) || !isdigit(ch)) |
134 | goto enoent; | 134 | goto enoent; |
135 | } | 135 | } |
@@ -137,9 +137,10 @@ inet_net_pton_ipv4(const char *src, u_char *dst, size_t size) | |||
137 | goto enoent; | 137 | goto enoent; |
138 | 138 | ||
139 | bits = -1; | 139 | bits = -1; |
140 | if (ch == '/' && isascii(src[0]) && isdigit(src[0]) && dst > odst) { | 140 | if (ch == '/' && isascii((unsigned char)src[0]) && |
141 | isdigit((unsigned char)src[0]) && dst > odst) { | ||
141 | /* CIDR width specifier. Nothing can follow it. */ | 142 | /* CIDR width specifier. Nothing can follow it. */ |
142 | ch = *src++; /* Skip over the /. */ | 143 | ch = (unsigned char)*src++; /* Skip over the /. */ |
143 | bits = 0; | 144 | bits = 0; |
144 | do { | 145 | do { |
145 | n = strchr(digits, ch) - digits; | 146 | n = strchr(digits, ch) - digits; |
@@ -148,7 +149,7 @@ inet_net_pton_ipv4(const char *src, u_char *dst, size_t size) | |||
148 | bits += n; | 149 | bits += n; |
149 | if (bits > 32) | 150 | if (bits > 32) |
150 | goto emsgsize; | 151 | goto emsgsize; |
151 | } while ((ch = *src++) != '\0' && | 152 | } while ((ch = (unsigned char)*src++) != '\0' && |
152 | isascii(ch) && isdigit(ch)); | 153 | isascii(ch) && isdigit(ch)); |
153 | if (ch != '\0') | 154 | if (ch != '\0') |
154 | goto enoent; | 155 | goto enoent; |