From a21f0c405df345f9ac6e331f71f09db8e340ca31 Mon Sep 17 00:00:00 2001 From: millert <> Date: Thu, 6 Jul 2017 16:23:11 +0000 Subject: 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@ --- src/lib/libc/stdlib/strtoumax.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/lib/libc/stdlib/strtoumax.c') 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 @@ -/* $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; -- cgit v1.2.3-55-g6feb