diff options
author | Gabriel Ravier <gabravier@gmail.com> | 2023-01-04 16:07:19 +0100 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2023-02-12 17:50:59 -0500 |
commit | 07616721f1fa6cb215ffbef23441cae80412484f (patch) | |
tree | 58c92a1039672246f43cc776bbbf5d93ad561169 /arch/i386/reloc.h | |
parent | 35fdfe62a4ff471074ca53b7626ec80e83d244bd (diff) | |
download | musl-07616721f1fa6cb215ffbef23441cae80412484f.tar.gz musl-07616721f1fa6cb215ffbef23441cae80412484f.tar.bz2 musl-07616721f1fa6cb215ffbef23441cae80412484f.tar.xz musl-07616721f1fa6cb215ffbef23441cae80412484f.zip |
fix return value of wcs{,n}cmp for extreme wchar_t values
As a result of using simple subtraction to implement the return values
for wcscmp and wcsncmp, integer overflow can occur (producing
undefined behavior, and in practice, a wrong comparison result). This
does not occur for meaningful character values (21-bit range) but the
functions are specified to work on arbitrary wchar_t arrays.
This patch replaces the subtraction with a little bit of code that
orders the characters correctly, returning -1 if the character from
the first string is smaller than the one from the second, 0 if they
are equal and 1 if the character from the first string is larger than
the one from the second.
Diffstat (limited to 'arch/i386/reloc.h')
0 files changed, 0 insertions, 0 deletions