Re: [PATCH] strtoul_ui: actually report error in case of negative input

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Sep 14, 2015 at 08:30:54AM +0200, Matthieu Moy wrote:
>> Fix it by changing the last check to trigger earlier, as soon as it
>> becomes bigger than INT_MAX.
> 
> What if the value is actually greater than INT_MAX? The function is
> returning an unsigned long (64 bits on 64bits architectures), and your
> version is restricting it to integers smaller than 2^31, right?

the return type of the function is "int", so this is not
going to work anyway.

As I mentioned, some negative values are still accepted
as coresponding mod 2**32 positive numbers (-3221225472 as
1073741824), so there really is room for improvement, but it
cannot be accomplished just by examining strtoul output.

I saw in the list archives an attempt to abandon the
function in favor of more accurate parser [1], but seems
like it did not make it into the project.

[1] http://thread.gmane.org/gmane.comp.version-control.git/265635

-- 
Max
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]