mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2025-09-10 07:59:52 +02:00
tail: avoid infloop with -c on /dev/zero
Problem reported by Ionut Nicula in: https://bugs.gnu.org/70477 * src/tail.c (tail_bytes): Do not loop forever on commands like 'tail -c 4096 /dev/zero'. * tests/tail/tail-c.sh: Test this fix.
This commit is contained in:
@@ -35,4 +35,14 @@ printf '123456' | tail -c3 > out || fail=1
|
||||
printf '456' > exp || framework_failure_
|
||||
compare exp out || fail=1
|
||||
|
||||
# Any part of /dev/zero should be valid for tail -c.
|
||||
head -c 4096 /dev/zero >exp || fail=1
|
||||
tail -c 4096 /dev/zero >out || fail=1
|
||||
compare exp out || fail=1
|
||||
|
||||
# Any part of /dev/urandom, if it exists, should be valid for tail -c.
|
||||
if test -r /dev/urandom; then
|
||||
timeout --verbose 1 tail -c 4096 /dev/urandom >/dev/null || fail=1
|
||||
fi
|
||||
|
||||
Exit $fail
|
||||
|
||||
Reference in New Issue
Block a user