Browse Source

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@
OPENBSD_6_2
millert 7 years ago
parent
commit
c212aadd9a
6 changed files with 18 additions and 18 deletions
  1. +3
    -3
      src/lib/libc/stdlib/strtoimax.c
  2. +3
    -3
      src/lib/libc/stdlib/strtol.c
  3. +3
    -3
      src/lib/libc/stdlib/strtoll.c
  4. +3
    -3
      src/lib/libc/stdlib/strtoul.c
  5. +3
    -3
      src/lib/libc/stdlib/strtoull.c
  6. +3
    -3
      src/lib/libc/stdlib/strtoumax.c

+ 3
- 3
src/lib/libc/stdlib/strtoimax.c View File

@ -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;


+ 3
- 3
src/lib/libc/stdlib/strtol.c View File

@ -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;


+ 3
- 3
src/lib/libc/stdlib/strtoll.c View File

@ -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;


+ 3
- 3
src/lib/libc/stdlib/strtoul.c View File

@ -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;


+ 3
- 3
src/lib/libc/stdlib/strtoull.c View File

@ -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;


+ 3
- 3
src/lib/libc/stdlib/strtoumax.c View File

@ -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;


Loading…
Cancel
Save