]> git.ipfire.org Git - thirdparty/coreutils.git/commit
factor: use 64-bit internal counters
authorPaul Eggert <eggert@cs.ucla.edu>
Thu, 10 Jul 2025 04:59:50 +0000 (21:59 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Thu, 10 Jul 2025 05:01:42 +0000 (22:01 -0700)
commit5b2ddab2d344195e63b80fd72e4b5d1867e2b91d
tree3be1e4ca794f6a4abf4ded7e09864dae57a550b0
parent4171ca33536219248afa1b74a561f1adc5739b64
factor: use 64-bit internal counters

* src/factor.c (factor_using_pollard_rho)
(factor_using_pollard_rho2, mp_factor_using_pollard_rho):
Use int_fast64_t for internal counters rather than int, as int
could overflow on some somewhat-practical examples.  Problem
discovered on a hypothetical platform where W_TYPE_SIZE is neither
32 nor 64, when factoring 0x7ffffffffffffeab7fffffffffff7369 ==
170141183460469225450570946617781744489, causing k to overflow in
mp_factor_using_pollard_rho.  Presumably a similar problem exists
in the previous stable coreutils 9.7, too, on 32-bit platforms
with somewhat-larger test cases, though I haven’t take the
somewhat-extensive CPU time to discover it.
src/factor.c