]> git.ipfire.org Git - thirdparty/vim.git/commit
patch 9.1.0089: qsort() comparison functions should be transitive v9.1.0089
authorChristian Brabandt <cb@256bit.org>
Fri, 9 Feb 2024 18:39:14 +0000 (19:39 +0100)
committerChristian Brabandt <cb@256bit.org>
Fri, 9 Feb 2024 18:39:14 +0000 (19:39 +0100)
commite06e43766500ecb4cd1031fa16cf9cbebdb222c1
tree5594099ce9de3e526002cd8601f3e734475f11eb
parentc9e79e52845d51f48f5ea3753a62ab3fe0e40184
patch 9.1.0089: qsort() comparison functions should be transitive

Problem:  qsort() comparison functions should be transitive
Solution: Do not subtract values, but rather use explicit comparisons

Improve qsort() comparison functions

There has been a recent report on qsort() causing out-of-bounds read &
write in glibc for non transitive comparison functions
https://www.qualys.com/2024/01/30/qsort.txt

Even so the bug is in glibc's implementation of the qsort() algorithm,
it's bad style to just use substraction for the comparison functions,
which may cause overflow issues and as hinted at in OpenBSD's manual
page for qsort(): "It is almost always an error to use subtraction to
compute the return value of the comparison function."

So check the qsort() comparison functions and change them to be safe.

closes: #13980

Signed-off-by: Christian Brabandt <cb@256bit.org>
src/ex_cmds.c
src/mbyte.c
src/profiler.c
src/search.c
src/spellsuggest.c
src/version.c
src/window.c