]> git.ipfire.org Git - thirdparty/coreutils.git/commit
sort: fix unlikely bug when '\377' < 0
authorPaul Eggert <eggert@cs.ucla.edu>
Sun, 10 Oct 2021 22:59:56 +0000 (15:59 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sun, 10 Oct 2021 23:06:28 +0000 (16:06 -0700)
commit6cafb122fa214baa96a67fbbd2dab6c77a961e0a
tree0c1a34948470dd3fdd21fed62e587a58c5a4f9b5
parent5b43b8e9ce215864001314f92097584bceb71b58
sort: fix unlikely bug when '\377' < 0

* gl/lib/strintcmp.c (strintcmp): Don’t assume that the input
cannot contain ((char) -1), as this equals '\377' when char is
signed (assuming 8-bit char).
* src/sort.c (decimal_point): Now char, to make it clear
that it’s always in char range now.
(NON_CHAR): New constant.
(traverse_raw_number): Return char not unsigned char;
this is simpler and could be faster.  All callers changed.
(main): Do not convert decimal_point and thousands_sep to
unsigned char, as this can mishandle comparisons on
machines where char is signed and the input data contains
((char) -1).  Use NON_CHAR, not -1, as an out-of-range value for
thousands_sep.
gl/lib/strintcmp.c
gl/lib/strnumcmp-in.h
src/sort.c