blob: 6922045563df7ed12a4ba24ea29463b3ce1e0f24 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
#!/bin/sh
# Ensure a stack overflow no longer segfaults
. "${srcdir=.}/init.sh"; path_prepend_ ../src
echo grep: stack overflow > exp || framework_failure_
# grep attempts to detect overflow via gnulib's c-stack module.
# Trigger that with an input regex composed solely of open parentheses,
# increasing the size of that input until grep emits the expected diagnostic.
fail=0
for i in 1 3 5 10 20 30 40 50 100 200; do
# Create a file containing $i * 10000 open parentheses:
printf %0${i}0000d 0|tr 0 '(' > in || framework_failure_
grep -E -f in >out 2>err; st=$?
if grep -q 'stack overflow' err; then
test $st = 2 || fail=1
compare /dev/null out || fail=1
compare exp err || fail=1
test $fail = 0 && Exit 0
fail_ 'printed "stack overflow", but something else was wrong'
fi
done
fail_ 'grep never printed "stack overflow"'
|