diff options
Diffstat (limited to 'src/grep/tests/kwset-abuse')
-rwxr-xr-x | src/grep/tests/kwset-abuse | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/grep/tests/kwset-abuse b/src/grep/tests/kwset-abuse new file mode 100755 index 0000000..bb8911f --- /dev/null +++ b/src/grep/tests/kwset-abuse @@ -0,0 +1,31 @@ +#! /bin/sh +# Evoke a segfault in a hard-to-reach code path of kwset.c. +# This bug affected grep versions 2.19 through 2.21. +# +# Copyright (C) 2015-2021 Free Software Foundation, Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. + +. "${srcdir=.}/init.sh"; path_prepend_ ../src + +fail=0 + +# This test case chooses a haystack of size 260,000, since prodding +# with gdb showed a reallocation slightly larger than that in fillbuf. +# To reach the buggy code, the needle must have length < 1/11 that of +# the haystack, and 10,000 is a nice round number that fits the bill. +printf '%0260000dXy\n' 0 | returns_ 1 grep -F $(printf %010000dy 0) \ + || fail=1 + +Exit $fail |