From dae2542cf4dc008b3b61b507d9ee18993ba9def4 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/strtoull.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/lib/libc/stdlib/strtoull.c') 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 @@ -/* $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; -- cgit v1.2.3-55-g6feb