diff options
Diffstat (limited to 'src/lib/libc/stdlib/strtoll.c')
-rw-r--r-- | src/lib/libc/stdlib/strtoll.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/lib/libc/stdlib/strtoll.c b/src/lib/libc/stdlib/strtoll.c index 4bcc5565be..cf82c8e1a6 100644 --- a/src/lib/libc/stdlib/strtoll.c +++ b/src/lib/libc/stdlib/strtoll.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* $OpenBSD: strtoll.c,v 1.7 2013/03/28 18:09:38 martynas Exp $ */ | 1 | /* $OpenBSD: strtoll.c,v 1.8 2014/09/13 20:10:12 schwarze 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. |
5 | * | 5 | * |
@@ -50,6 +50,17 @@ strtoll(const char *nptr, char **endptr, int base) | |||
50 | int neg, any, cutlim; | 50 | int neg, any, cutlim; |
51 | 51 | ||
52 | /* | 52 | /* |
53 | * Ensure that base is between 2 and 36 inclusive, or the special | ||
54 | * value of 0. | ||
55 | */ | ||
56 | if (base < 0 || base == 1 || base > 36) { | ||
57 | if (endptr != 0) | ||
58 | *endptr = (char *)nptr; | ||
59 | errno = EINVAL; | ||
60 | return 0; | ||
61 | } | ||
62 | |||
63 | /* | ||
53 | * Skip white space and pick up leading +/- sign if any. | 64 | * Skip white space and pick up leading +/- sign if any. |
54 | * If base is 0, allow 0x for hex and 0 for octal, else | 65 | * If base is 0, allow 0x for hex and 0 for octal, else |
55 | * assume decimal; if base is already 16, allow 0x. | 66 | * assume decimal; if base is already 16, allow 0x. |