From 5331255b6eeafa74865b2e6af627cb712c41dafd Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Wed, 30 Apr 2014 12:57:51 -0700 Subject: Fix v9/64-bit strcmp when string ends in multiple zero bytes. [BZ #16885] * sysdeps/sparc/sparc64/strcmp.S: Fix end comparison handling when multiple zero bytes exist at the end of a string. Reported by Aurelien Jarno * string/test-strcmp.c (check): Add explicit test for situations where there are multiple zero bytes after the first. --- string/test-strcmp.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'string/test-strcmp.c') diff --git a/string/test-strcmp.c b/string/test-strcmp.c index b395dc7fbe..fcd059f30a 100644 --- a/string/test-strcmp.c +++ b/string/test-strcmp.c @@ -329,6 +329,34 @@ check (void) FOR_EACH_IMPL (impl, 0) check_result (impl, s1 + i1, s2 + i2, exp_result); } + + /* Test cases where there are multiple zero bytes after the first. */ + + for (size_t i = 0; i < 16 + 1; i++) + { + s1[i] = 0x00; + s2[i] = 0x00; + } + + for (size_t i = 0; i < 16; i++) + { + int exp_result; + + for (int val = 0x01; val < 0x100; val++) + { + for (size_t j = 0; j < i; j++) + { + s1[j] = val; + s2[j] = val; + } + + s2[i] = val; + + exp_result = SIMPLE_STRCMP (s1, s2); + FOR_EACH_IMPL (impl, 0) + check_result (impl, s1, s2, exp_result); + } + } } -- cgit v1.2.3