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.)
This commit is contained in:
Andrey A. Chernov 1995-08-01 21:38:00 +00:00
parent 4777741358
commit 2bdca0d9f0
1 changed files with 3 additions and 1 deletions

View File

@ -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))