forked from coreutils/coreutils
Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
sort: fix buffer overflow with some case conversions
* src/sort.c (keycompare_mb): Ensure the buffer is big enough to handle anything output from wctomb(). The current implementation is character based, so we allocate the worst case size for the conversion buffer, which is MB_CUR_MAX for each input byte. * tests/i18n/sort.sh: Add a test case causing seg fault. * tests/local.mk: Reference the new test case. Reported at https://bugzilla.suse.com/show_bug.cgi?id=928749
- Loading branch information
Showing
3 changed files
with
34 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| #!/bin/sh | ||
| # Verify sort's multi-byte support. | ||
|
|
||
| . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src | ||
| print_ver_ sort | ||
|
|
||
| export LC_ALL=en_US.UTF-8 | ||
| locale -k LC_CTYPE | grep -q "charmap.*UTF-8" \ | ||
| || skip_ "No UTF-8 locale available" | ||
|
|
||
| # Enable heap consistency checkng on older systems | ||
| export MALLOC_CHECK_=2 | ||
|
|
||
|
|
||
| # check buffer overflow issue due to | ||
| # expanding multi-byte representation due to case conversion | ||
| # https://bugzilla.suse.com/show_bug.cgi?id=928749 | ||
| cat <<EOF > exp | ||
| . | ||
| ɑ | ||
| EOF | ||
| cat <<EOF | sort -f > out || fail=1 | ||
| . | ||
| ɑ | ||
| EOF | ||
| compare exp out || { fail=1; cat out; } | ||
|
|
||
|
|
||
| Exit $fail |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters