diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2017-07-06 16:23:12 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2017-07-06 16:23:12 +0000 |
commit | f87f3d752026a09c2ab5fd6f0d1a65901c943135 (patch) | |
tree | 295cbcbbf76ec03340af72c423c5621360e9c9c0 /lib/libc/stdlib | |
parent | aacfa61fe6f0ed89b75bb346647e86a73d0a36b7 (diff) |
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')
-rw-r--r-- | lib/libc/stdlib/strtoimax.c | 6 | ||||
-rw-r--r-- | lib/libc/stdlib/strtol.c | 6 | ||||
-rw-r--r-- | lib/libc/stdlib/strtoll.c | 6 | ||||
-rw-r--r-- | lib/libc/stdlib/strtoul.c | 6 | ||||
-rw-r--r-- | lib/libc/stdlib/strtoull.c | 6 | ||||
-rw-r--r-- | lib/libc/stdlib/strtoumax.c | 6 |
6 files changed, 18 insertions, 18 deletions
diff --git a/lib/libc/stdlib/strtoimax.c b/lib/libc/stdlib/strtoimax.c index 52403a72134..74e355626af 100644 --- a/lib/libc/stdlib/strtoimax.c +++ b/lib/libc/stdlib/strtoimax.c @@ -1,4 +1,4 @@ -/* $OpenBSD: strtoimax.c,v 1.3 2015/09/12 16:23:14 guenther Exp $ */ +/* $OpenBSD: strtoimax.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. @@ -74,8 +74,8 @@ strtoimax(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; diff --git a/lib/libc/stdlib/strtol.c b/lib/libc/stdlib/strtol.c index 49465e28ee8..599d2355a89 100644 --- a/lib/libc/stdlib/strtol.c +++ b/lib/libc/stdlib/strtol.c @@ -1,4 +1,4 @@ -/* $OpenBSD: strtol.c,v 1.11 2015/09/13 08:31:48 guenther Exp $ */ +/* $OpenBSD: strtol.c,v 1.12 2017/07/06 16:23:11 millert Exp $ */ /* * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. @@ -75,8 +75,8 @@ strtol(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; diff --git a/lib/libc/stdlib/strtoll.c b/lib/libc/stdlib/strtoll.c index 0ba51da77e8..d21a249a0b8 100644 --- a/lib/libc/stdlib/strtoll.c +++ b/lib/libc/stdlib/strtoll.c @@ -1,4 +1,4 @@ -/* $OpenBSD: strtoll.c,v 1.9 2015/09/13 08:31:48 guenther Exp $ */ +/* $OpenBSD: strtoll.c,v 1.10 2017/07/06 16:23:11 millert Exp $ */ /* * Copyright (c) 1992 The Regents of the University of California. * All rights reserved. @@ -77,8 +77,8 @@ strtoll(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; 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; diff --git a/lib/libc/stdlib/strtoull.c b/lib/libc/stdlib/strtoull.c index a5d07de6cff..d7733e40031 100644 --- a/lib/libc/stdlib/strtoull.c +++ b/lib/libc/stdlib/strtoull.c @@ -1,4 +1,4 @@ -/* $OpenBSD: strtoull.c,v 1.8 2015/09/13 08:31:48 guenther Exp $ */ +/* $OpenBSD: strtoull.c,v 1.9 2017/07/06 16:23:11 millert Exp $ */ /* * Copyright (c) 1992 The Regents of the University of California. * All rights reserved. @@ -71,8 +71,8 @@ strtoull(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; 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; |