summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdlib/strtol.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/stdlib/strtol.c')
-rw-r--r--lib/libc/stdlib/strtol.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/libc/stdlib/strtol.c b/lib/libc/stdlib/strtol.c
index 1a7f7b3..18e3972 100644
--- a/lib/libc/stdlib/strtol.c
+++ b/lib/libc/stdlib/strtol.c
@@ -55,7 +55,7 @@ strtol(nptr, endptr, base)
{
register const char *s = nptr;
register unsigned long acc;
- register int c;
+ register unsigned char c;
register unsigned long cutoff;
register int neg = 0, any, cutlim;
@@ -102,6 +102,8 @@ strtol(nptr, endptr, base)
cutlim = cutoff % (unsigned long)base;
cutoff /= (unsigned long)base;
for (acc = 0, any = 0;; c = *s++) {
+ if (!isascii(c))
+ break;
if (isdigit(c))
c -= '0';
else if (isalpha(c))
@@ -110,7 +112,7 @@ strtol(nptr, endptr, base)
break;
if (c >= base)
break;
- if (any < 0 || acc > cutoff || acc == cutoff && c > cutlim)
+ if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
any = -1;
else {
any = 1;
OpenPOWER on IntegriCloud