SHA256
1
0
forked from pool/glibc
glibc/strstr-huge-needle.patch
Andreas Schwab 9a39949079 Accepting request 638790 from home:Andreas_Schwab:Factory
- unwind-ctor.patch: Add missing unwind information to ld.so on powerpc32
  (BZ #23707)
- old-getdents64.patch: Rewrite __old_getdents64 (BZ #23497)
- nss-files-leak.patch: Fix file stream leak in aliases lookup (BZ #23521)
- riscv-feholdexcept-setround.patch: Fix rounding save/restore bug
- pthread-cond-broadcast-waiters-after-spinning.patch: Fix
  waiters-after-spinning case (BZ #23538)
- regex-uninit-memory-access.patch: fix uninitialized memory access (BZ
  #23578)
- spawni-maybe-script-execute.patch: Fix segfault in maybe_script_execute
- gethostid-gethostbyname-failure.patch: Check for NULL value from
  gethostbyname_r (BZ #23679)
- strstr-huge-needle.patch: Fix strstr bug with huge needles (BZ #23637)

OBS-URL: https://build.opensuse.org/request/show/638790
OBS-URL: https://build.opensuse.org/package/show/Base:System/glibc?expand=0&rev=511
2018-09-27 13:22:16 +00:00

96 lines
2.6 KiB
Diff

2018-09-19 Wilco Dijkstra <wdijkstr@arm.com>
[BZ #23637]
* string/test-strstr.c (pr23637): New function.
(test_main): Add tests with longer needles.
* string/strcasestr.c (AVAILABLE): Fix readahead distance.
* string/strstr.c (AVAILABLE): Likewise.
Index: glibc-2.28/string/strcasestr.c
===================================================================
--- glibc-2.28.orig/string/strcasestr.c
+++ glibc-2.28/string/strcasestr.c
@@ -37,8 +37,9 @@
/* Two-Way algorithm. */
#define RETURN_TYPE char *
#define AVAILABLE(h, h_l, j, n_l) \
- (((j) + (n_l) <= (h_l)) || ((h_l) += __strnlen ((void*)((h) + (h_l)), 512), \
- (j) + (n_l) <= (h_l)))
+ (((j) + (n_l) <= (h_l)) \
+ || ((h_l) += __strnlen ((void*)((h) + (h_l)), (n_l) + 512), \
+ (j) + (n_l) <= (h_l)))
#define CHECK_EOL (1)
#define RET0_IF_0(a) if (!a) goto ret0
#define CANON_ELEMENT(c) TOLOWER (c)
Index: glibc-2.28/string/strstr.c
===================================================================
--- glibc-2.28.orig/string/strstr.c
+++ glibc-2.28/string/strstr.c
@@ -33,8 +33,9 @@
#define RETURN_TYPE char *
#define AVAILABLE(h, h_l, j, n_l) \
- (((j) + (n_l) <= (h_l)) || ((h_l) += __strnlen ((void*)((h) + (h_l)), 512), \
- (j) + (n_l) <= (h_l)))
+ (((j) + (n_l) <= (h_l)) \
+ || ((h_l) += __strnlen ((void*)((h) + (h_l)), (n_l) + 512), \
+ (j) + (n_l) <= (h_l)))
#define CHECK_EOL (1)
#define RET0_IF_0(a) if (!a) goto ret0
#define FASTSEARCH(S,C,N) (void*) strchr ((void*)(S), (C))
Index: glibc-2.28/string/test-strstr.c
===================================================================
--- glibc-2.28.orig/string/test-strstr.c
+++ glibc-2.28/string/test-strstr.c
@@ -151,6 +151,32 @@ check2 (void)
}
}
+#define N 1024
+
+static void
+pr23637 (void)
+{
+ char *h = (char*) buf1;
+ char *n = (char*) buf2;
+
+ for (int i = 0; i < N; i++)
+ {
+ n[i] = 'x';
+ h[i] = ' ';
+ h[i + N] = 'x';
+ }
+
+ n[N] = '\0';
+ h[N * 2] = '\0';
+
+ /* Ensure we don't match at the first 'x'. */
+ h[0] = 'x';
+
+ char *exp_result = stupid_strstr (h, n);
+ FOR_EACH_IMPL (impl, 0)
+ check_result (impl, h, n, exp_result);
+}
+
static int
test_main (void)
{
@@ -158,6 +184,7 @@ test_main (void)
check1 ();
check2 ();
+ pr23637 ();
printf ("%23s", "");
FOR_EACH_IMPL (impl, 0)
@@ -202,6 +229,9 @@ test_main (void)
do_test (15, 9, hlen, klen, 1);
do_test (15, 15, hlen, klen, 0);
do_test (15, 15, hlen, klen, 1);
+
+ do_test (15, 15, hlen + klen * 4, klen * 4, 0);
+ do_test (15, 15, hlen + klen * 4, klen * 4, 1);
}
do_test (0, 0, page_size - 1, 16, 0);