vfprintf typing problem
David Miller
davem@davemloft.net
Sat Mar 31 22:25:00 GMT 2012
From: "Carlos O'Donell" <carlos@systemhalted.org>
Date: Sat, 31 Mar 2012 18:02:43 -0400
> On Sat, Mar 31, 2012 at 5:19 PM, David Miller <davem@davemloft.net> wrote:
>> @@ -77,9 +77,11 @@ read_int (const UCHAR_T * *pstr)
>> {
>> retval *= 10;
>> retval += **pstr - L_('0');
>> + if (retval > INT_MAX)
>> + return -1;
>
> Is this correct?
>
> If in the previous iteration we were less than INT_MAX, given the "*
> 10 + [0-9]" we might wrap the unsigned int retval to a positive value
> e.g. 429,496,729 * 10 + 6 = 0, and not detect the signed int overflow?
>
> What am I missing?
Indeed, I need to check for overflow before the addition.
Please review the patch with that fix implied :-)
More information about the Libc-alpha
mailing list