Re: [PATCH] fix potential infinite loop given large unsigned integer

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

 



Ryan Flynn <parseerror@xxxxxxxxx> writes:

> given n, tried to find i greater than n via i=1, iterate i *= 10.
> given n sufficiently close to UINT_MAX this will overflow; which can
> produce i==0, which results in an infinite loop. iteratively dividing
> n /= 10 does not have this problem, and though division is slower than
> multiplication this only runs once per `git format-patch
> --cover-letter`
>
> Signed-off-by: pizza <parseerror@xxxxxxxxx>

Pizza?

This is somewhat amusing.

 - digits_in_number() is called only with opt->total that is "int";

 - opt->total is the total number of patches.

 - the return value is used like this:

     sprintf(buf, "%0*d", digits_in_number(opt->total), opt->nr);

   and opt->nr runs from 1 to opt->total; the use of "d" would be already
   wrong anyway even if you computed digits_in_number() correctly.

Perhaps we should get rid of this function altogether?
--
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]