summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>1995-08-01 21:38:00 +0000
committerache <ache@FreeBSD.org>1995-08-01 21:38:00 +0000
commit9246df9bb49151b04bae525154ca52e5695dab53 (patch)
treea7cc5f8cd9ee78eb06acaa8b471f9f271b924922 /lib
parent21cc29328e0ec5d81f23c44eb23b19d99f7e691f (diff)
downloadFreeBSD-src-9246df9bb49151b04bae525154ca52e5695dab53.zip
FreeBSD-src-9246df9bb49151b04bae525154ca52e5695dab53.tar.gz
strtol and atoi VERY broken in 8bit chars locale, i.e. if you pass something
like 38400<any 8bit char, isalpha> it not detect this stuff and produce very big number instead. Fixed by operating with unsigned char and checking for isascii. (secure/telnetd hits by it f.e.)
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/stdlib/strtol.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/libc/stdlib/strtol.c b/lib/libc/stdlib/strtol.c
index 1a7f7b3..3e6ec70 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))
OpenPOWER on IntegriCloud