]>
Commit | Line | Data |
---|---|---|
12788f63 MT |
1 | 2010-10-06 Ulrich Drepper <drepper@gmail.com> |
2 | ||
3 | * string/bug-strstr1.c: New file. | |
4 | * string/Makefile: Add rules to build and run bug-strstr1. | |
5 | ||
6 | 2010-10-05 Eric Blake <eblake@redhat.com> | |
7 | ||
8 | [BZ #12092] | |
9 | * string/str-two-way.h (two_way_long_needle): Always clear memory | |
10 | when skipping input due to the shift table. | |
11 | ||
12 | Index: glibc-2.12-2-gc4ccff1/string/Makefile | |
13 | =================================================================== | |
14 | --- glibc-2.12-2-gc4ccff1.orig/string/Makefile | |
15 | +++ glibc-2.12-2-gc4ccff1/string/Makefile | |
16 | @@ -54,7 +54,8 @@ tests := tester inl-tester noinl-tester | |
17 | bug-strncat1 bug-strspn1 bug-strpbrk1 tst-bswap \ | |
18 | tst-strtok tst-strxfrm bug-strcoll1 tst-strfry \ | |
19 | bug-strtok1 $(addprefix test-,$(strop-tests)) \ | |
20 | - bug-envz1 tst-strxfrm2 tst-endian tst-svc2 | |
21 | + bug-envz1 tst-strxfrm2 tst-endian tst-svc2 \ | |
22 | + bug-strstr1 | |
23 | distribute := memcopy.h pagecopy.h tst-svc.expect test-string.h \ | |
24 | str-two-way.h | |
25 | ||
26 | @@ -73,6 +74,7 @@ CFLAGS-tst-strlen.c = -fno-builtin | |
27 | CFLAGS-stratcliff.c = -fno-builtin | |
28 | CFLAGS-test-ffs.c = -fno-builtin | |
29 | CFLAGS-tst-inlcall.c = -fno-builtin | |
30 | +CFLAGS-bug-strstr1.c = -fno-builtin | |
31 | ||
32 | ifeq ($(cross-compiling),no) | |
33 | tests: $(objpfx)tst-svc.out | |
34 | Index: glibc-2.12-2-gc4ccff1/string/bug-strstr1.c | |
35 | =================================================================== | |
36 | --- /dev/null | |
37 | +++ glibc-2.12-2-gc4ccff1/string/bug-strstr1.c | |
38 | @@ -0,0 +1,26 @@ | |
39 | +#include <stdio.h> | |
40 | +#include <string.h> | |
41 | + | |
42 | +int main (int argc, char** argv) | |
43 | +{ | |
44 | + const char haystack[] = | |
45 | + "F_BD_CE_BD_EF_BF_BD_EF_BF_BD_EF_BF_BD_EF_BF_BD_C3_88_20_EF_BF_BD_EF_BF_BD_EF_BF_BD_C3_A7_20_EF_BF_BD"; | |
46 | + | |
47 | + const char needle[] = | |
48 | + "_EF_BF_BD_EF_BF_BD_EF_BF_BD_EF_BF_BD_EF_BF_BD"; | |
49 | + | |
50 | + const char* sub = strstr (haystack, needle); | |
51 | + | |
52 | + if (sub != NULL) | |
53 | + { | |
54 | + int j; | |
55 | + | |
56 | + fprintf (stderr, "BUG: expected NULL, got:\n%s\n%s\n", sub, needle); | |
57 | + for (j = 0; needle[j] != '\0'; ++j) | |
58 | + putchar (needle[j] == sub[j] ? ' ' : '^'); | |
59 | + puts (""); | |
60 | + return 1; | |
61 | + } | |
62 | + | |
63 | + return 0; | |
64 | +} | |
65 | Index: glibc-2.12-2-gc4ccff1/string/str-two-way.h | |
66 | =================================================================== | |
67 | --- glibc-2.12-2-gc4ccff1.orig/string/str-two-way.h | |
68 | +++ glibc-2.12-2-gc4ccff1/string/str-two-way.h | |
69 | @@ -350,8 +350,8 @@ two_way_long_needle (const unsigned char | |
70 | a byte out of place, there can be no match until | |
71 | after the mismatch. */ | |
72 | shift = needle_len - period; | |
73 | - memory = 0; | |
74 | } | |
75 | + memory = 0; | |
76 | j += shift; | |
77 | continue; | |
78 | } |