Blame SOURCES/glibc-rh641128.patch

b9ba6d
2010-10-06  Ulrich Drepper  <drepper@gmail.com>
b9ba6d
b9ba6d
	* string/bug-strstr1.c: New file.
b9ba6d
	* string/Makefile: Add rules to build and run bug-strstr1.
b9ba6d
b9ba6d
2010-10-05  Eric Blake  <eblake@redhat.com>
b9ba6d
b9ba6d
	[BZ #12092]
b9ba6d
	* string/str-two-way.h (two_way_long_needle): Always clear memory
b9ba6d
	when skipping input due to the shift table.
b9ba6d
b9ba6d
Index: glibc-2.12-2-gc4ccff1/string/Makefile
b9ba6d
===================================================================
b9ba6d
--- glibc-2.12-2-gc4ccff1.orig/string/Makefile
b9ba6d
+++ glibc-2.12-2-gc4ccff1/string/Makefile
b9ba6d
@@ -54,7 +54,8 @@ tests		:= tester inl-tester noinl-tester
b9ba6d
 		   bug-strncat1 bug-strspn1 bug-strpbrk1 tst-bswap	\
b9ba6d
 		   tst-strtok tst-strxfrm bug-strcoll1 tst-strfry	\
b9ba6d
 		   bug-strtok1 $(addprefix test-,$(strop-tests))	\
b9ba6d
-		   bug-envz1 tst-strxfrm2 tst-endian tst-svc2
b9ba6d
+		   bug-envz1 tst-strxfrm2 tst-endian tst-svc2		\
b9ba6d
+		   bug-strstr1
b9ba6d
 distribute	:= memcopy.h pagecopy.h tst-svc.expect test-string.h	\
b9ba6d
 		   str-two-way.h
b9ba6d
 
b9ba6d
@@ -73,6 +74,7 @@ CFLAGS-tst-strlen.c = -fno-builtin
b9ba6d
 CFLAGS-stratcliff.c = -fno-builtin
b9ba6d
 CFLAGS-test-ffs.c = -fno-builtin
b9ba6d
 CFLAGS-tst-inlcall.c = -fno-builtin
b9ba6d
+CFLAGS-bug-strstr1.c = -fno-builtin
b9ba6d
 
b9ba6d
 ifeq ($(cross-compiling),no)
b9ba6d
 tests: $(objpfx)tst-svc.out
b9ba6d
Index: glibc-2.12-2-gc4ccff1/string/bug-strstr1.c
b9ba6d
===================================================================
b9ba6d
--- /dev/null
b9ba6d
+++ glibc-2.12-2-gc4ccff1/string/bug-strstr1.c
b9ba6d
@@ -0,0 +1,26 @@
b9ba6d
+#include <stdio.h>
b9ba6d
+#include <string.h>
b9ba6d
+
b9ba6d
+int main (int argc, char** argv)
b9ba6d
+{
b9ba6d
+  const char haystack[] =
b9ba6d
+    "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";
b9ba6d
+
b9ba6d
+  const char needle[] =
b9ba6d
+    "_EF_BF_BD_EF_BF_BD_EF_BF_BD_EF_BF_BD_EF_BF_BD";
b9ba6d
+
b9ba6d
+  const char* sub = strstr (haystack, needle);
b9ba6d
+
b9ba6d
+  if (sub != NULL)
b9ba6d
+    {
b9ba6d
+      int j;
b9ba6d
+
b9ba6d
+      fprintf (stderr, "BUG: expected NULL, got:\n%s\n%s\n", sub, needle);
b9ba6d
+      for (j = 0; needle[j] != '\0'; ++j)
b9ba6d
+        putchar (needle[j] == sub[j] ? ' ' : '^');
b9ba6d
+      puts ("");
b9ba6d
+      return 1;
b9ba6d
+    }
b9ba6d
+
b9ba6d
+  return 0;
b9ba6d
+}
b9ba6d
Index: glibc-2.12-2-gc4ccff1/string/str-two-way.h
b9ba6d
===================================================================
b9ba6d
--- glibc-2.12-2-gc4ccff1.orig/string/str-two-way.h
b9ba6d
+++ glibc-2.12-2-gc4ccff1/string/str-two-way.h
b9ba6d
@@ -350,8 +350,8 @@ two_way_long_needle (const unsigned char
b9ba6d
 		     a byte out of place, there can be no match until
b9ba6d
 		     after the mismatch.  */
b9ba6d
 		  shift = needle_len - period;
b9ba6d
-		  memory = 0;
b9ba6d
 		}
b9ba6d
+	      memory = 0;
b9ba6d
 	      j += shift;
b9ba6d
 	      continue;
b9ba6d
 	    }