SHA256
1
0
forked from pool/coreutils

s/MB_CUR_MAX/MB_LEN_MAX/, and add a test case

OBS-URL: https://build.opensuse.org/package/show/Base:System/coreutils?expand=0&rev=257
This commit is contained in:
Bernhard Voelker 2015-05-12 15:42:22 +00:00 committed by Git OBS Bridge
parent feef8ae1a8
commit 2a760ea199
4 changed files with 58 additions and 11 deletions

View File

@ -7,7 +7,8 @@
src/sort.c | 743 +++++++++++++++++++++++++++++++++++++++++--- src/sort.c | 743 +++++++++++++++++++++++++++++++++++++++++---
src/unexpand.c | 228 +++++++++++++ src/unexpand.c | 228 +++++++++++++
src/uniq.c | 265 +++++++++++++++ src/uniq.c | 265 +++++++++++++++
tests/local.mk | 1 tests/i18n/sort.sh | 29 +
tests/local.mk | 2
tests/misc/cut.pl | 7 tests/misc/cut.pl | 7
tests/misc/expand.pl | 40 ++ tests/misc/expand.pl | 40 ++
tests/misc/fold.pl | 50 ++ tests/misc/fold.pl | 50 ++
@ -18,7 +19,7 @@
tests/misc/unexpand.pl | 39 ++ tests/misc/unexpand.pl | 39 ++
tests/misc/uniq.pl | 55 +++ tests/misc/uniq.pl | 55 +++
tests/pr/pr-tests.pl | 49 ++ tests/pr/pr-tests.pl | 49 ++
20 files changed, 3194 insertions(+), 180 deletions(-) 21 files changed, 3224 insertions(+), 180 deletions(-)
Index: lib/linebuffer.h Index: lib/linebuffer.h
=================================================================== ===================================================================
@ -3261,8 +3262,8 @@ Index: src/sort.c
+ +
+ if (ignore || translate) + if (ignore || translate)
+ { + {
+ char *copy_a = (char *) xmalloc((lena + lenb) * MB_CUR_MAX + 2); + char *copy_a = (char *) xmalloc((lena + lenb) * MB_LEN_MAX + 2);
+ char *copy_b = copy_a + (lena * MB_CUR_MAX) + 1; + char *copy_b = copy_a + (lena * MB_LEN_MAX) + 1;
+ size_t new_len_a, new_len_b; + size_t new_len_a, new_len_b;
+ size_t i, j; + size_t i, j;
+ +
@ -4112,6 +4113,14 @@ Index: tests/local.mk
tests/misc/sort-merge.pl \ tests/misc/sort-merge.pl \
tests/misc/sort-merge-fdlimit.sh \ tests/misc/sort-merge-fdlimit.sh \
tests/misc/sort-month.sh \ tests/misc/sort-month.sh \
@@ -516,6 +517,7 @@ all_tests = \
tests/du/threshold.sh \
tests/du/trailing-slash.sh \
tests/du/two-args.sh \
+ tests/i18n/sort.sh \
tests/id/gnu-zero-uids.sh \
tests/id/no-context.sh \
tests/id/context.sh \
Index: tests/misc/cut.pl Index: tests/misc/cut.pl
=================================================================== ===================================================================
--- tests/misc/cut.pl.orig --- tests/misc/cut.pl.orig
@ -4718,3 +4727,37 @@ Index: tests/pr/pr-tests.pl
my $save_temps = $ENV{DEBUG}; my $save_temps = $ENV{DEBUG};
my $verbose = $ENV{VERBOSE}; my $verbose = $ENV{VERBOSE};
Index: tests/i18n/sort.sh
===================================================================
--- /dev/null
+++ tests/i18n/sort.sh
@@ -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

View File

@ -16,7 +16,7 @@ Index: tests/local.mk
=================================================================== ===================================================================
--- tests/local.mk.orig --- tests/local.mk.orig
+++ tests/local.mk +++ tests/local.mk
@@ -661,14 +661,9 @@ all_tests = \ @@ -662,14 +662,9 @@ all_tests = \
# See tests/factor/create-test.sh. # See tests/factor/create-test.sh.
tf = tests/factor tf = tests/factor
factor_tests = \ factor_tests = \

View File

@ -8,9 +8,11 @@ Tue May 12 09:32:53 UTC 2015 - mail@bernhard-voelker.de
Tue May 12 08:56:13 UTC 2015 - mail@bernhard-voelker.de Tue May 12 08:56:13 UTC 2015 - mail@bernhard-voelker.de
- Fix memory handling error with case insensitive sort using UTF-8 - Fix memory handling error with case insensitive sort using UTF-8
(boo#928749): (boo#928749): coreutils-i18n.patch
* coreutils-i18n.patch: Allocate more memory as the upper form of src/sort.c (keycompare_mb): Ensure the buffer is big enough
some multi-byte characters may be 1 byte wider. to handle anything output from wctomb(). Theoretically any
input char could be converted to multiple output chars,
and so we need to multiply the storage by MB_LEN_MAX.
------------------------------------------------------------------- -------------------------------------------------------------------
Tue Apr 7 18:18:31 UTC 2015 - crrodriguez@opensuse.org Tue Apr 7 18:18:31 UTC 2015 - crrodriguez@opensuse.org

View File

@ -8,9 +8,11 @@ Tue May 12 09:32:53 UTC 2015 - mail@bernhard-voelker.de
Tue May 12 08:56:13 UTC 2015 - mail@bernhard-voelker.de Tue May 12 08:56:13 UTC 2015 - mail@bernhard-voelker.de
- Fix memory handling error with case insensitive sort using UTF-8 - Fix memory handling error with case insensitive sort using UTF-8
(boo#928749): (boo#928749): coreutils-i18n.patch
* coreutils-i18n.patch: Allocate more memory as the upper form of src/sort.c (keycompare_mb): Ensure the buffer is big enough
some multi-byte characters may be 1 byte wider. to handle anything output from wctomb(). Theoretically any
input char could be converted to multiple output chars,
and so we need to multiply the storage by MB_LEN_MAX.
------------------------------------------------------------------- -------------------------------------------------------------------
Tue Apr 7 18:18:31 UTC 2015 - crrodriguez@opensuse.org Tue Apr 7 18:18:31 UTC 2015 - crrodriguez@opensuse.org