diff options
author | Pádraig Brady <P@draigBrady.com> | 2023-03-07 01:12:12 +0000 |
---|---|---|
committer | Pádraig Brady <P@draigBrady.com> | 2023-03-07 01:14:00 +0000 |
commit | 35ac97e0d601d5a20bf986bad052f0f94a504561 (patch) | |
tree | 24b7033884d2cbd36a20fa5ce0427fdacb840a39 /tests | |
parent | a4778006c8f2b669afcc45456acf0d21f228208d (diff) | |
download | coreutils-35ac97e0d601d5a20bf986bad052f0f94a504561.tar.gz |
tee: fix a crash with unwriteable files
This was introduced recently with commit v9.1-166-g6b12e62d9
* src/tee.c (tee_files): Check the return from fopen()
before passing to fileno() etc.
* tests/misc/tee.sh: Add a test case.
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/misc/tee.sh | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/tests/misc/tee.sh b/tests/misc/tee.sh index 30d64a9d2..63e7524c0 100755 --- a/tests/misc/tee.sh +++ b/tests/misc/tee.sh @@ -74,6 +74,11 @@ retry_delay_ tee_exited .1 7 | # 12.7s (Must be > following timeout) test $(wc -l < err) = 0 || { cat err; fail=1; } test -f tee.exited || fail=1 +# Test with unwriteable files +touch file.ro || framework_failure_ +chmod a-w file.ro || framework_failure_ +returns_ 1 tee -p </dev/null file.ro || fail=1 + # Ensure tee honors --output-error modes mkfifo_or_skip_ fifo read_fifo() { timeout 10 dd count=1 if=fifo of=/dev/null status=none & } |