diff options
author | 2014-09-13 20:10:12 +0000 | |
---|---|---|
committer | 2014-09-13 20:10:12 +0000 | |
commit | b252b5f6e1f8ed74b8fe0b3449eb72f4b9ca5f57 (patch) | |
tree | 5ae51484372ab07338f3115e93c87b33cf125245 /lib/libc/stdlib/strtol.c | |
parent | Don't say or imply that using ifconfig has anything to do with whether the (diff) | |
download | wireguard-openbsd-b252b5f6e1f8ed74b8fe0b3449eb72f4b9ca5f57.tar.xz wireguard-openbsd-b252b5f6e1f8ed74b8fe0b3449eb72f4b9ca5f57.zip |
Make sure that the following functions return 0 and EINVAL as
required by the C standard when called with an invalid base:
strtoll(), strtoimax(), strtoul(), strtoull(), and strtoumax().
Same behaviour for strtoq() and strtouq() even though not standardized.
No functional change in strtol(), it was the only one already correct.
While here, simplify the conditional expression for checking the base
and sync whitespace and comments among the six files.
ok millert@
Diffstat (limited to 'lib/libc/stdlib/strtol.c')
-rw-r--r-- | lib/libc/stdlib/strtol.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/lib/libc/stdlib/strtol.c b/lib/libc/stdlib/strtol.c index dc2cf8871cc..86cec350864 100644 --- a/lib/libc/stdlib/strtol.c +++ b/lib/libc/stdlib/strtol.c @@ -1,5 +1,5 @@ -/* $OpenBSD: strtol.c,v 1.9 2013/04/17 17:40:35 tedu Exp $ */ -/*- +/* $OpenBSD: strtol.c,v 1.10 2014/09/13 20:10:12 schwarze Exp $ */ +/* * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. * @@ -33,7 +33,6 @@ #include <limits.h> #include <stdlib.h> - /* * Convert a string to a long integer. * @@ -52,7 +51,7 @@ strtol(const char *nptr, char **endptr, int base) * Ensure that base is between 2 and 36 inclusive, or the special * value of 0. */ - if (base != 0 && (base < 2 || base > 36)) { + if (base < 0 || base == 1 || base > 36) { if (endptr != 0) *endptr = (char *)nptr; errno = EINVAL; |