diff options
| author | millert <> | 2017-07-06 16:23:11 +0000 |
|---|---|---|
| committer | millert <> | 2017-07-06 16:23:11 +0000 |
| commit | dae2542cf4dc008b3b61b507d9ee18993ba9def4 (patch) | |
| tree | 26f60c0a26bc547b49545722cdc2d4a6192d7562 /src/lib/libc/stdlib/strtoul.c | |
| parent | 4633cfbfe1188ff5cdb819c2aa46163c0d1cfe3e (diff) | |
| download | openbsd-dae2542cf4dc008b3b61b507d9ee18993ba9def4.tar.gz openbsd-dae2542cf4dc008b3b61b507d9ee18993ba9def4.tar.bz2 openbsd-dae2542cf4dc008b3b61b507d9ee18993ba9def4.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 '')
| -rw-r--r-- | src/lib/libc/stdlib/strtoul.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/lib/libc/stdlib/strtoul.c b/src/lib/libc/stdlib/strtoul.c index 98e8abcbdb..6667bea8fa 100644 --- a/src/lib/libc/stdlib/strtoul.c +++ b/src/lib/libc/stdlib/strtoul.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: strtoul.c,v 1.10 2015/09/13 08:31:48 guenther Exp $ */ | 1 | /* $OpenBSD: strtoul.c,v 1.11 2017/07/06 16:23:11 millert Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (c) 1990 The Regents of the University of California. | 3 | * Copyright (c) 1990 The Regents of the University of California. |
| 4 | * All rights reserved. | 4 | * All rights reserved. |
| @@ -69,8 +69,8 @@ strtoul(const char *nptr, char **endptr, int base) | |||
| 69 | if (c == '+') | 69 | if (c == '+') |
| 70 | c = *s++; | 70 | c = *s++; |
| 71 | } | 71 | } |
| 72 | if ((base == 0 || base == 16) && | 72 | if ((base == 0 || base == 16) && c == '0' && |
| 73 | c == '0' && (*s == 'x' || *s == 'X')) { | 73 | (*s == 'x' || *s == 'X') && isxdigit((unsigned char)s[1])) { |
| 74 | c = s[1]; | 74 | c = s[1]; |
| 75 | s += 2; | 75 | s += 2; |
| 76 | base = 16; | 76 | base = 16; |
