summaryrefslogtreecommitdiff
path: root/stdlib/strtol.c
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/strtol.c')
-rw-r--r--stdlib/strtol.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/stdlib/strtol.c b/stdlib/strtol.c
index c38f61c52f..5a097b40a4 100644
--- a/stdlib/strtol.c
+++ b/stdlib/strtol.c
@@ -201,7 +201,10 @@ INTERNAL (strtol) (nptr, endptr, base, group)
#endif
if (base < 0 || base == 1 || base > 36)
- base = 10;
+ {
+ __set_errno (EINVAL);
+ return 0;
+ }
save = s = nptr;
@@ -214,8 +217,13 @@ INTERNAL (strtol) (nptr, endptr, base, group)
/* Check for a sign. */
if (*s == L_('-'))
{
+#if UNSIGNED
+ __set_errno (EINVAL);
+ return 0;
+#else
negative = 1;
++s;
+#endif
}
else if (*s == L_('+'))
{