The libstdc++ Parallel Mode (enabled by _GLIBCXX_PARALLEL or by
including the relevant headers and calling the functionss explicitly)
uses the Knuth-Morris-Pratt search algorithm. A VLA is declared for the
borders, but it uses N elements not N+1, leading to an out-of-bounds
write in the parallel std::search.
libstdc++-v3/ChangeLog:
* include/parallel/search.h (__search_template): Increase array
size.
---
No new test because the bug only causes problems with ASan which we
can't use in the testsuite. I verified it manually though.
Tested x86_64-linux.
Needed on trunk and all active branches.
libstdc++-v3/include/parallel/search.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libstdc++-v3/include/parallel/search.h
b/libstdc++-v3/include/parallel/search.h
index f055c5b18b54..34bd51619c38 100644
--- a/libstdc++-v3/include/parallel/search.h
+++ b/libstdc++-v3/include/parallel/search.h
@@ -111,7 +111,7 @@ namespace __gnu_parallel
(1, std::min<_DifferenceType>(__input_length,
__get_max_threads()));
- _DifferenceType __advances[__pattern_length];
+ _DifferenceType __advances[__pattern_length + 1];
__calc_borders(__begin2, __pattern_length, __advances);
# pragma omp parallel num_threads(__num_threads)
--
2.56.0