This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 2/4] Detect EOL on-the-fly in strstr, strcasestr and memmem.


On Fri, Oct 5, 2012 at 1:21 PM, Roland McGrath <roland@hack.frob.com> wrote:
>> This test case then becomes:
>>
>>       [BZ #14602]
>>       * string/test-strstr.c (check2): New function.
>>       (test_main): Call check2.
>
> That looks OK to me.

I checked in this patch to check page boundary.  It catches
strstr reads beyond the end of string.

-- 
H.J.
---
2012-10-06  H.J. Lu  <hongjiu.lu@intel.com>

	* string/test-strstr.c (check2): Add a test for page boundary.

diff --git a/string/test-strstr.c b/string/test-strstr.c
index a29b2c9..22a00f9 100644
--- a/string/test-strstr.c
+++ b/string/test-strstr.c
@@ -162,10 +162,15 @@ check2 (void)
 {
   const char s1[] = ", enable_static, \0, enable_shared, ";
   char *exp_result;
+  char *s2 = (void *) buf1 + page_size - 18;

+  strcpy (s2, s1);
   exp_result = stupid_strstr (s1, s1 + 18);
   FOR_EACH_IMPL (impl, 0)
-    check_result (impl, s1, s1 + 18, exp_result);
+    {
+      check_result (impl, s1, s1 + 18, exp_result);
+      check_result (impl, s2, s1 + 18, exp_result);
+    }
 }

 static int


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]