diff options
author | 2017-07-06 16:23:11 +0000 | |
---|---|---|
committer | 2017-07-06 16:23:11 +0000 | |
commit | 6022c2c21c00ed222314d1a82f05f5778bfe1e32 (patch) | |
tree | e443b9b2cd22244c94bdda0d882caaec6db4c5af /lib/libc/stdlib/strtoul.c | |
parent | fix broken cross references; found with mandoc -Tlint (diff) | |
download | wireguard-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/strtoul.c')
-rw-r--r-- | lib/libc/stdlib/strtoul.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/libc/stdlib/strtoul.c b/lib/libc/stdlib/strtoul.c index 98e8abcbdba..6667bea8fac 100644 --- a/lib/libc/stdlib/strtoul.c +++ b/lib/libc/stdlib/strtoul.c @@ -1,4 +1,4 @@ -/* $OpenBSD: strtoul.c,v 1.10 2015/09/13 08:31:48 guenther Exp $ */ +/* $OpenBSD: strtoul.c,v 1.11 2017/07/06 16:23:11 millert Exp $ */ /* * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. @@ -69,8 +69,8 @@ strtoul(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; |