fix potential overflow in exponent reading
authorRich Felker <dalias@aerifal.cx>
Wed, 11 Apr 2012 03:05:16 +0000 (23:05 -0400)
committerRich Felker <dalias@aerifal.cx>
Wed, 11 Apr 2012 03:05:16 +0000 (23:05 -0400)
note that there's no need for a precise cutoff, because exponents this
large will always result in overflow or underflow (it's impossible to
read enough digits to compensate for the exponent magnitude; even at a
few nanoseconds per digit it would take hundreds of years).

src/internal/floatscan.c

index 3875719b42e064bd5b15e104a9ddb8b4abee8cf5..ed73527867322217f8932f630e5084721dfee18a 100644 (file)
@@ -44,7 +44,7 @@ static long long scanexp(FILE *f, int pok)
        }
        for (x=0; c-'0'<10U && x<INT_MAX/10; c = shgetc(f))
                x = 10*x + c-'0';
-       for (y=x; c-'0'<10U && x<LLONG_MAX/10; c = shgetc(f))
+       for (y=x; c-'0'<10U && x<LLONG_MAX/100; c = shgetc(f))
                y = 10*y + c-'0';
        for (; c-'0'<10U; c = shgetc(f));
        shunget(f);