Re: [PATCH] lib/kstrtox.c clean kstrtoll function

From: Anshul Garg
Date: Fri Jan 23 2015 - 08:25:45 EST


Dear Mr. Jeff,

Thanks for the comments.

Yes i think overflow check logic is wrong.

So i think we can change the overflow logic -

>From --

if ((long long)tmp < 0)
+ return -ERANGE;

to -

if (((long long)tmp < LLONG_MIN) || ((long long)tmp > LLONG_MAX) )
+ return -ERANGE;

Please give your views on this change..
If this change seems correct i will update overflow logic
in my sent patch.


Hope to hear from you soon.

Thanks
Anshul Garg


On Thu, Jan 22, 2015 at 10:55 PM, Jeff Epler <jepler@xxxxxxxxxxxxxx> wrote:
> On Thu, Jan 22, 2015 at 05:54:10AM -0800, Anshul Garg wrote:
>> - if ((long long)(-tmp) >= 0)
>> - return -ERANGE;
>> - *res = -tmp;
> ...
>> + if ((long long)tmp < 0)
>> + return -ERANGE;
>> + *res = sign * tmp;
>
> I don't believe overflow handling is correct anymore with this patch.
> Did you try with the input as the most negative possible unsigned long?
>
> Jeff
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/