]> git.ipfire.org Git - thirdparty/coreutils.git/commit
sort: fix unlikely int overflow with -r
authorPaul Eggert <eggert@cs.ucla.edu>
Wed, 18 May 2022 02:30:09 +0000 (19:30 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Wed, 18 May 2022 02:30:55 +0000 (19:30 -0700)
commita351fdd6fcbc48ccd337a111d24fe9fa3c0d58c3
tree008c6db7765724baa5b79a7364cb3d593166a91d
parent5864e8f919c3dae827016ac1a78544db90403b6d
sort: fix unlikely int overflow with -r

* src/sort.c (keycompare, compare): Don’t overflow if -r is
specified and a comparison function returns INT_MIN, as this
causes the comparison to have undefined behavior (typically the
reverse of correct).  glibc memcmp on s390x reportedly returns
INT_MIN in some cases, so this is not a purely academic issue.
src/sort.c