This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH] Fix strncmp page test to limit length to size of object
- From: Andreas Schwab <schwab at redhat dot com>
- To: libc-alpha at sourceware dot org
- Date: Tue, 29 Mar 2011 10:44:48 +0200
- Subject: [PATCH] Fix strncmp page test to limit length to size of object
- References: <m2vcz3rsio.fsf@igel.home><1301349529.12961.60.camel@localhost.localdomain><m2r59qsy6w.fsf@igel.home>
Let's fix the test instead.
Andreas.
2011-03-29 Andreas Schwab <schwab@redhat.com>
* string/test-strncmp.c (do_page_test): Limit length to size of
object.
---
string/test-strncmp.c | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/string/test-strncmp.c b/string/test-strncmp.c
index 00971df..880b2be 100644
--- a/string/test-strncmp.c
+++ b/string/test-strncmp.c
@@ -204,6 +204,7 @@ do_page_test (size_t offset1, size_t offset2, char *s2)
{
char *s1;
int exp_result;
+ size_t max_offset = offset1 > offset2 ? offset1 : offset2;
if (offset1 >= page_size || offset2 >= page_size)
return;
@@ -211,12 +212,12 @@ do_page_test (size_t offset1, size_t offset2, char *s2)
s1 = (char *) (buf1 + offset1);
s2 += offset2;
- exp_result= *s1;
+ exp_result = *s1;
FOR_EACH_IMPL (impl, 0)
{
- check_result (impl, s1, s2, page_size, -exp_result);
- check_result (impl, s2, s1, page_size, exp_result);
+ check_result (impl, s1, s2, page_size - max_offset, -exp_result);
+ check_result (impl, s2, s1, page_size - max_offset, exp_result);
}
}
--
1.7.4
--
Andreas Schwab, schwab@redhat.com
GPG Key fingerprint = D4E8 DBE3 3813 BB5D FA84 5EC7 45C6 250E 6F00 984E
"And now for something completely different."