summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormillert <>2017-07-06 16:23:11 +0000
committermillert <>2017-07-06 16:23:11 +0000
commita21f0c405df345f9ac6e331f71f09db8e340ca31 (patch)
tree26f60c0a26bc547b49545722cdc2d4a6192d7562 /src
parent22e44168d1f1914a6642ee8c247b8ed5cc2fe51e (diff)
downloadopenbsd-a21f0c405df345f9ac6e331f71f09db8e340ca31.tar.gz
openbsd-a21f0c405df345f9ac6e331f71f09db8e340ca31.tar.bz2
openbsd-a21f0c405df345f9ac6e331f71f09db8e340ca31.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 'src')
-rw-r--r--src/lib/libc/stdlib/strtoimax.c6
-rw-r--r--src/lib/libc/stdlib/strtol.c6
-rw-r--r--src/lib/libc/stdlib/strtoll.c6
-rw-r--r--src/lib/libc/stdlib/strtoul.c6
-rw-r--r--src/lib/libc/stdlib/strtoull.c6
-rw-r--r--src/lib/libc/stdlib/strtoumax.c6
6 files changed, 18 insertions, 18 deletions
diff --git a/src/lib/libc/stdlib/strtoimax.c b/src/lib/libc/stdlib/strtoimax.c
index 52403a7213..74e355626a 100644
--- a/src/lib/libc/stdlib/strtoimax.c
+++ b/src/lib/libc/stdlib/strtoimax.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: strtoimax.c,v 1.3 2015/09/12 16:23:14 guenther Exp $ */ 1/* $OpenBSD: strtoimax.c,v 1.4 2017/07/06 16:23:11 millert Exp $ */
2/* 2/*
3 * Copyright (c) 1992 The Regents of the University of California. 3 * Copyright (c) 1992 The Regents of the University of California.
4 * All rights reserved. 4 * All rights reserved.
@@ -74,8 +74,8 @@ strtoimax(const char *nptr, char **endptr, int base)
74 if (c == '+') 74 if (c == '+')
75 c = *s++; 75 c = *s++;
76 } 76 }
77 if ((base == 0 || base == 16) && 77 if ((base == 0 || base == 16) && c == '0' &&
78 c == '0' && (*s == 'x' || *s == 'X')) { 78 (*s == 'x' || *s == 'X') && isxdigit((unsigned char)s[1])) {
79 c = s[1]; 79 c = s[1];
80 s += 2; 80 s += 2;
81 base = 16; 81 base = 16;
diff --git a/src/lib/libc/stdlib/strtol.c b/src/lib/libc/stdlib/strtol.c
index 49465e28ee..599d2355a8 100644
--- a/src/lib/libc/stdlib/strtol.c
+++ b/src/lib/libc/stdlib/strtol.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: strtol.c,v 1.11 2015/09/13 08:31:48 guenther Exp $ */ 1/* $OpenBSD: strtol.c,v 1.12 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.
@@ -75,8 +75,8 @@ strtol(const char *nptr, char **endptr, int base)
75 if (c == '+') 75 if (c == '+')
76 c = *s++; 76 c = *s++;
77 } 77 }
78 if ((base == 0 || base == 16) && 78 if ((base == 0 || base == 16) && c == '0' &&
79 c == '0' && (*s == 'x' || *s == 'X')) { 79 (*s == 'x' || *s == 'X') && isxdigit((unsigned char)s[1])) {
80 c = s[1]; 80 c = s[1];
81 s += 2; 81 s += 2;
82 base = 16; 82 base = 16;
diff --git a/src/lib/libc/stdlib/strtoll.c b/src/lib/libc/stdlib/strtoll.c
index 0ba51da77e..d21a249a0b 100644
--- a/src/lib/libc/stdlib/strtoll.c
+++ b/src/lib/libc/stdlib/strtoll.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: strtoll.c,v 1.9 2015/09/13 08:31:48 guenther Exp $ */ 1/* $OpenBSD: strtoll.c,v 1.10 2017/07/06 16:23:11 millert Exp $ */
2/* 2/*
3 * Copyright (c) 1992 The Regents of the University of California. 3 * Copyright (c) 1992 The Regents of the University of California.
4 * All rights reserved. 4 * All rights reserved.
@@ -77,8 +77,8 @@ strtoll(const char *nptr, char **endptr, int base)
77 if (c == '+') 77 if (c == '+')
78 c = *s++; 78 c = *s++;
79 } 79 }
80 if ((base == 0 || base == 16) && 80 if ((base == 0 || base == 16) && c == '0' &&
81 c == '0' && (*s == 'x' || *s == 'X')) { 81 (*s == 'x' || *s == 'X') && isxdigit((unsigned char)s[1])) {
82 c = s[1]; 82 c = s[1];
83 s += 2; 83 s += 2;
84 base = 16; 84 base = 16;
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;
diff --git a/src/lib/libc/stdlib/strtoull.c b/src/lib/libc/stdlib/strtoull.c
index a5d07de6cf..d7733e4003 100644
--- a/src/lib/libc/stdlib/strtoull.c
+++ b/src/lib/libc/stdlib/strtoull.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: strtoull.c,v 1.8 2015/09/13 08:31:48 guenther Exp $ */ 1/* $OpenBSD: strtoull.c,v 1.9 2017/07/06 16:23:11 millert Exp $ */
2/* 2/*
3 * Copyright (c) 1992 The Regents of the University of California. 3 * Copyright (c) 1992 The Regents of the University of California.
4 * All rights reserved. 4 * All rights reserved.
@@ -71,8 +71,8 @@ strtoull(const char *nptr, char **endptr, int base)
71 if (c == '+') 71 if (c == '+')
72 c = *s++; 72 c = *s++;
73 } 73 }
74 if ((base == 0 || base == 16) && 74 if ((base == 0 || base == 16) && c == '0' &&
75 c == '0' && (*s == 'x' || *s == 'X')) { 75 (*s == 'x' || *s == 'X') && isxdigit((unsigned char)s[1])) {
76 c = s[1]; 76 c = s[1];
77 s += 2; 77 s += 2;
78 base = 16; 78 base = 16;
diff --git a/src/lib/libc/stdlib/strtoumax.c b/src/lib/libc/stdlib/strtoumax.c
index 4c5e3349f1..348184c1ac 100644
--- a/src/lib/libc/stdlib/strtoumax.c
+++ b/src/lib/libc/stdlib/strtoumax.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: strtoumax.c,v 1.3 2015/09/12 16:23:14 guenther Exp $ */ 1/* $OpenBSD: strtoumax.c,v 1.4 2017/07/06 16:23:11 millert Exp $ */
2/* 2/*
3 * Copyright (c) 1992 The Regents of the University of California. 3 * Copyright (c) 1992 The Regents of the University of California.
4 * All rights reserved. 4 * All rights reserved.
@@ -68,8 +68,8 @@ strtoumax(const char *nptr, char **endptr, int base)
68 if (c == '+') 68 if (c == '+')
69 c = *s++; 69 c = *s++;
70 } 70 }
71 if ((base == 0 || base == 16) && 71 if ((base == 0 || base == 16) && c == '0' &&
72 c == '0' && (*s == 'x' || *s == 'X')) { 72 (*s == 'x' || *s == 'X') && isxdigit((unsigned char)s[1])) {
73 c = s[1]; 73 c = s[1];
74 s += 2; 74 s += 2;
75 base = 16; 75 base = 16;