summaryrefslogtreecommitdiff
path: root/src/lib/libc/stdlib/strtoimax.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libc/stdlib/strtoimax.c')
-rw-r--r--src/lib/libc/stdlib/strtoimax.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/lib/libc/stdlib/strtoimax.c b/src/lib/libc/stdlib/strtoimax.c
index 2c77f41650..2fc04e4850 100644
--- a/src/lib/libc/stdlib/strtoimax.c
+++ b/src/lib/libc/stdlib/strtoimax.c
@@ -1,6 +1,5 @@
1/* $OpenBSD: strtoimax.c,v 1.1 2006/01/13 17:58:09 millert Exp $ */ 1/* $OpenBSD: strtoimax.c,v 1.2 2014/09/13 20:10:12 schwarze Exp $ */
2 2/*
3/*-
4 * Copyright (c) 1992 The Regents of the University of California. 3 * Copyright (c) 1992 The Regents of the University of California.
5 * All rights reserved. 4 * All rights reserved.
6 * 5 *
@@ -48,6 +47,17 @@ strtoimax(const char *nptr, char **endptr, int base)
48 int neg, any, cutlim; 47 int neg, any, cutlim;
49 48
50 /* 49 /*
50 * Ensure that base is between 2 and 36 inclusive, or the special
51 * value of 0.
52 */
53 if (base < 0 || base == 1 || base > 36) {
54 if (endptr != 0)
55 *endptr = (char *)nptr;
56 errno = EINVAL;
57 return 0;
58 }
59
60 /*
51 * Skip white space and pick up leading +/- sign if any. 61 * Skip white space and pick up leading +/- sign if any.
52 * If base is 0, allow 0x for hex and 0 for octal, else 62 * If base is 0, allow 0x for hex and 0 for octal, else
53 * assume decimal; if base is already 16, allow 0x. 63 * assume decimal; if base is already 16, allow 0x.