mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-28 00:21:52 +03:00
Fix strstr bug with huge needles (bug 23637)
The generic strstr in GLIBC 2.28 fails to match huge needles. The optimized AVAILABLE macro reads ahead a large fixed amount to reduce the overhead of repeatedly checking for the end of the string. However if the needle length is larger than this, two_way_long_needle may confuse this as meaning the end of the string and return NULL. This is fixed by adding the needle length to the amount to read ahead. [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.
This commit is contained in:
@ -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))
|
||||
|
Reference in New Issue
Block a user