From 6f30a99fa537adb029283cf2ef03cb4419350e6c Mon Sep 17 00:00:00 2001 From: Pádraig Brady
Date: Sun, 27 Nov 2016 13:00:35 +0000 Subject: tail: fix uninitialized memory read when failing to read file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reproduced under UBSAN with `tail -f <&-` giving: tail.c:2220:18: runtime error: load of value 190, which is not a valid value for type ‘_Bool' * src/tail.c (tail_file): Ensure f->ignore is initialized in all cases where we can't tail the specified file. * tests/tail-2/follow-stdin.sh: Add a test case which checks stderr has no UBSAN warnings. Fixes http://bugs.gnu.org/25041 --- tests/tail-2/follow-stdin.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'tests') diff --git a/tests/tail-2/follow-stdin.sh b/tests/tail-2/follow-stdin.sh index a2f180428..3d51f6006 100755 --- a/tests/tail-2/follow-stdin.sh +++ b/tests/tail-2/follow-stdin.sh @@ -50,4 +50,16 @@ for mode in '' '---disable-inotify'; do cleanup_ done + +# Before coreutils-8.26 this would induce an UMR under UBSAN +returns_ 1 timeout 10 tail -f - <&- 2>err || fail=1 +cat <<\EOF >exp || framework_failure_ +tail: cannot fstat 'standard input': Bad file descriptor +tail: error reading 'standard input': Bad file descriptor +tail: no files remaining +tail: -: Bad file descriptor +EOF +compare exp err || fail=1 + + Exit $fail -- cgit v1.2.3-70-g09d2