3 # Copyright (C) 2008-2016 Free Software Foundation, Inc.
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 .
"${srcdir=.}/tests/init.sh"; path_prepend_ .
/src
21 # Trigger a heap-clobbering bug in ptx from coreutils-6.10 and earlier.
22 # Using a long file name makes an abort more likely.
23 # Even with no file name, valgrind detects the buffer overrun.
24 f
=01234567890123456789012345678901234567890123456789
25 touch $f empty || framework_failure_
27 # Specifying a regular expression ending in a lone backslash
28 # would cause ptx to write beyond the end of a malloc'd buffer.
29 ptx -F '\' $f < /dev/null > out || fail=1
30 ptx -S 'foo
\' $f < /dev
/null
>> out || fail
=1
31 ptx -W 'bar\\\' $f < /dev/null >> out || fail=1
32 compare out empty || fail=1
35 # Trigger an invalid heap reference noticed by gcc -fsanitize=address
36 # from coreutils-8.22 and earlier. As well as an invalid memory reference,
37 # the issue can be seen in the output, with non deterministice whitespace
38 # trimming when multiple files are specified.
39 printf '%s
\n' 'This is a
ptx whitespace Trimming
test' > ws.in
40 ptx ws.in ws.in | sort | uniq -u > out
41 compare /dev/null out || fail=1
44 # Trigger an invalid heap reference noticed by gcc -fsanitize=address
45 # from coreutils-8.25 and earlier.
47 ptx -w1 -A $PWD/a >/dev/null || fail=1