Use calloc() instead of malloc() to avoid a possible multiplication overflow.
NB: This was the cheapest way I was able to make the test introduced in eab91d008165e7bbf8ca7b87eabe4dc8bf3da191 pass.
Differential D41040
xargs: Avoid a possible multiplication overflow jlduran on Jul 14 2023, 10:07 PM. Authored by Tags None Referenced Files
Subscribers
Details Use calloc() instead of malloc() to avoid a possible multiplication overflow. NB: This was the cheapest way I was able to make the test introduced in eab91d008165e7bbf8ca7b87eabe4dc8bf3da191 pass. # kyua debug legacy_test:main 1..22 ok - normal # Test detected no regression. (in .) ok - I # Test detected no regression. (in .) ok - J # Test detected no regression. (in .) ok - L # Test detected no regression. (in .) ok - P1 # Test detected no regression. (in .) ok - R # Test detected no regression. (in .) ok - R-1 # Test detected no regression. (in .) ok - n1 # Test detected no regression. (in .) ok - n2 # Test detected no regression. (in .) ok - n2147483647 # Test detected no regression. (in .) ok - n2P0 # Test detected no regression. (in .) ok - n3 # Test detected no regression. (in .) ok - 0 # Test detected no regression. (in .) ok - 0I # Test detected no regression. (in .) ok - 0J # Test detected no regression. (in .) ok - 0L # Test detected no regression. (in .) ok - 0P1 # Test detected no regression. (in .) ok - quotes # Test detected no regression. (in .) ok - parallel1 # Test detected no regression. (in .) ok - parallel2 # Test detected no regression. (in .) ok - parallel3 # Test detected no regression. (in .) ok - parallel4 # Test detected no regression. (in .) legacy_test:main -> passed
Diff Detail
Event Timeline
Comment Actions One other possible solution would be something like this (untested): -# This test may consume a large amount of memory, making it unsuited to CI -# environments. Disable it for now. -#REGRESSION_TEST(`n2147483647', `xargs -n2147483647 <${SRCDIR}/regress.in') +REGRESSION_TEST(`n2147483647', `MALLOC_CONF=junk:false xargs -n2147483647 <${SRCDIR}/regress.in') That assumes that jemalloc is the malloc implementation in use, but I suspect it's harmless otherwise. |