Fix strncmp page test to limit length to size of object
authorAndreas Schwab <schwab@redhat.com>
Tue, 29 Mar 2011 08:40:28 +0000 (10:40 +0200)
committerAndreas Schwab <schwab@redhat.com>
Tue, 5 Apr 2011 11:45:23 +0000 (13:45 +0200)
ChangeLog
string/test-strncmp.c

index fe86bc9..2f2ec75 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2011-04-05  Andreas Schwab  <schwab@redhat.com>
+
+       * string/test-strncmp.c (do_page_test): Limit length to size of
+       object.
+
 2011-04-03  Ulrich Drepper  <drepper@gmail.com>
 
        * sysdeps/x86_64/cacheinfo.c (intel_02_known): Fix typo in table.
index 00971df..880b2be 100644 (file)
@@ -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);
     }
 }