From cf65182f8b05e806af310a6d2fa559e46e674e56 Mon Sep 17 00:00:00 2001 From: deraadt <> Date: Mon, 25 Nov 2013 18:23:51 +0000 Subject: unsigned char changes for ctype re-re-reviewed by krw --- src/lib/libc/net/inet_net_pton.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'src/lib/libc/net/inet_net_pton.c') 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 @@ -/* $OpenBSD: inet_net_pton.c,v 1.7 2012/06/22 19:13:37 gilles Exp $ */ +/* $OpenBSD: inet_net_pton.c,v 1.8 2013/11/25 18:23:51 deraadt Exp $ */ /* * Copyright (c) 2012 by Gilles Chehade @@ -85,16 +85,16 @@ inet_net_pton_ipv4(const char *src, u_char *dst, size_t size) int n, ch, tmp, dirty, bits; const u_char *odst = dst; - ch = *src++; + ch = (unsigned char)*src++; if (ch == '0' && (src[0] == 'x' || src[0] == 'X') - && isascii(src[1]) && isxdigit(src[1])) { + && isascii((unsigned char)src[1]) && isxdigit((unsigned char)src[1])) { /* Hexadecimal: Eat nybble string. */ if (size <= 0) goto emsgsize; *dst = 0, dirty = 0; src++; /* skip x or X. */ - while ((ch = *src++) != '\0' && - isascii(ch) && isxdigit(ch)) { + while ((ch = (unsigned char)*src++) != '\0' && + isascii(ch) && isxdigit(ch)) { if (isupper(ch)) ch = tolower(ch); n = strchr(xdigits, ch) - xdigits; @@ -120,7 +120,7 @@ inet_net_pton_ipv4(const char *src, u_char *dst, size_t size) tmp += n; if (tmp > 255) goto enoent; - } while ((ch = *src++) != '\0' && + } while ((ch = (unsigned char)*src++) != '\0' && isascii(ch) && isdigit(ch)); if (size-- <= 0) goto emsgsize; @@ -129,7 +129,7 @@ inet_net_pton_ipv4(const char *src, u_char *dst, size_t size) break; if (ch != '.') goto enoent; - ch = *src++; + ch = (unsigned char)*src++; if (!isascii(ch) || !isdigit(ch)) goto enoent; } @@ -137,9 +137,10 @@ inet_net_pton_ipv4(const char *src, u_char *dst, size_t size) goto enoent; bits = -1; - if (ch == '/' && isascii(src[0]) && isdigit(src[0]) && dst > odst) { + if (ch == '/' && isascii((unsigned char)src[0]) && + isdigit((unsigned char)src[0]) && dst > odst) { /* CIDR width specifier. Nothing can follow it. */ - ch = *src++; /* Skip over the /. */ + ch = (unsigned char)*src++; /* Skip over the /. */ bits = 0; do { n = strchr(digits, ch) - digits; @@ -148,7 +149,7 @@ inet_net_pton_ipv4(const char *src, u_char *dst, size_t size) bits += n; if (bits > 32) goto emsgsize; - } while ((ch = *src++) != '\0' && + } while ((ch = (unsigned char)*src++) != '\0' && isascii(ch) && isdigit(ch)); if (ch != '\0') goto enoent; -- cgit v1.2.3-55-g6feb