This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH 2/4] Detect EOL on-the-fly in strstr, strcasestr and memmem.
On Tue, Oct 9, 2012 at 12:36 AM, Andreas Jaeger <aj@suse.com> wrote:
> On Tuesday, October 09, 2012 20:11:16 Maxim Kuvyrkov wrote:
>> On 9/10/2012, at 8:06 PM, Andreas Jaeger wrote:
>> > On Monday, October 08, 2012 15:09:11 Carlos O'Donell wrote:
>> ...
>>
>> >> I'm reviewed this and it looks correct.
>> >>
>> >> OK to checkin as long as you add comments for CHECK_AVAILABLE_AFTER
>> >> in the header str-two-way.h or somewhere else.
>> >>
>> >> I'd like this conditional to be well documented for future
>> >> maintainers.
>> >
>> > Could we have this backported to 2.16, please?
>>
>> Andreas,
>>
>> This fix is not needed on 2.16 as the patch that introduced the bug
>> went into 2.17 trunk.
>
> Thanks, then everything is fine.
It caused:
http://sourceware.org/bugzilla/show_bug.cgi?id=14716
Here is a patch for testcase. It is also on hjl/pr14716 branch.
--
H.J.
--
[BZ #14716]
* string/test-memmem.c (check_result): New function.
(do_one_test): Use it.
(check1): New function.
(test_main): Use it.
diff --git a/string/test-memmem.c b/string/test-memmem.c
index 4076029..5f32a0e 100644
--- a/string/test-memmem.c
+++ b/string/test-memmem.c
@@ -56,8 +56,8 @@ simple_memmem (const void *haystack, size_t
haystack_len, const void *needle,
return NULL;
}
-static void
-do_one_test (impl_t *impl, const void *haystack, size_t haystack_len,
+static int
+check_result (impl_t *impl, const void *haystack, size_t haystack_len,
const void *needle, size_t needle_len, const void *expected)
{
void *res;
@@ -68,9 +68,20 @@ do_one_test (impl_t *impl, const void *haystack,
size_t haystack_len,
error (0, 0, "Wrong result in function %s %p %p", impl->name,
res, expected);
ret = 1;
- return;
+ return -1;
}
+ return 0;
+}
+
+static void
+do_one_test (impl_t *impl, const void *haystack, size_t haystack_len,
+ const void *needle, size_t needle_len, const void *expected)
+{
+ if (check_result (impl, haystack, haystack_len, needle, needle_len,
+ expected) < 0)
+ return;
+
if (HP_TIMING_AVAIL)
{
hp_timing_t start __attribute ((unused));
@@ -145,6 +156,22 @@ do_random_tests (void)
}
}
+static void
+check1 (void)
+{
+
+ const char search_buf_data[5] = { 0x56, 0x34, 0x12, 0x78, 0x78 };
+ const char pattern[2] = { 0x78, 0x56 };
+ void *search_buf = (void *) buf1 + page_size - sizeof search_buf_data;
+ void *exp_result;
+
+ memcpy (search_buf, search_buf_data, sizeof search_buf_data);
+ exp_result = simple_memmem (search_buf, sizeof search_buf_data,
+ pattern, sizeof pattern);
+ FOR_EACH_IMPL (impl, 0)
+ check_result (impl, search_buf, sizeof search_buf_data,
+ pattern, sizeof pattern, exp_result);
+}
static const char *const strs[] =
{
@@ -161,6 +188,8 @@ test_main (void)
test_init ();
+ check1 ();
+
printf ("%23s", "");
FOR_EACH_IMPL (impl, 0)
printf ("\t%s", impl->name);
--
1.7.11.4