summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdlib/strtoumax.c
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>2017-07-06 16:23:11 +0000
committermillert <millert@openbsd.org>2017-07-06 16:23:11 +0000
commit6022c2c21c00ed222314d1a82f05f5778bfe1e32 (patch)
treee443b9b2cd22244c94bdda0d882caaec6db4c5af /lib/libc/stdlib/strtoumax.c
parentfix broken cross references; found with mandoc -Tlint (diff)
downloadwireguard-openbsd-6022c2c21c00ed222314d1a82f05f5778bfe1e32.tar.xz
wireguard-openbsd-6022c2c21c00ed222314d1a82f05f5778bfe1e32.zip
The 0x (or 0X) prefix in base 16 is optional so only skip over the
prefix if the character following it is a valid hex char. The C99 standard is clear that given the string "0xy" zero should be returned and endptr set to point to the "x". OK deraadt@ espie@
Diffstat (limited to 'lib/libc/stdlib/strtoumax.c')
-rw-r--r--lib/libc/stdlib/strtoumax.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/libc/stdlib/strtoumax.c b/lib/libc/stdlib/strtoumax.c
index 4c5e3349f11..348184c1ac4 100644
--- a/lib/libc/stdlib/strtoumax.c
+++ b/lib/libc/stdlib/strtoumax.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: strtoumax.c,v 1.3 2015/09/12 16:23:14 guenther Exp $ */
+/* $OpenBSD: strtoumax.c,v 1.4 2017/07/06 16:23:11 millert Exp $ */
/*
* Copyright (c) 1992 The Regents of the University of California.
* All rights reserved.
@@ -68,8 +68,8 @@ strtoumax(const char *nptr, char **endptr, int base)
if (c == '+')
c = *s++;
}
- if ((base == 0 || base == 16) &&
- c == '0' && (*s == 'x' || *s == 'X')) {
+ if ((base == 0 || base == 16) && c == '0' &&
+ (*s == 'x' || *s == 'X') && isxdigit((unsigned char)s[1])) {
c = s[1];
s += 2;
base = 16;