From debbugs-submit-bounces@debbugs.gnu.org Sun Nov 27 04:15:42 2016 Received: (at submit) by debbugs.gnu.org; 27 Nov 2016 09:15:42 +0000 Received: from localhost ([127.0.0.1]:42881 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cAvYk-0004rX-L8 for submit@debbugs.gnu.org; Sun, 27 Nov 2016 04:15:42 -0500 Received: from eggs.gnu.org ([208.118.235.92]:37933) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cAvYi-0004rL-N3 for submit@debbugs.gnu.org; Sun, 27 Nov 2016 04:15:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cAvYc-0000pG-DY for submit@debbugs.gnu.org; Sun, 27 Nov 2016 04:15:35 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM, T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:46606) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cAvYc-0000pA-A2 for submit@debbugs.gnu.org; Sun, 27 Nov 2016 04:15:34 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57137) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cAvYb-0001kC-7f for bug-coreutils@gnu.org; Sun, 27 Nov 2016 04:15:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cAvYX-0000nS-0J for bug-coreutils@gnu.org; Sun, 27 Nov 2016 04:15:33 -0500 Received: from mail-pg0-x234.google.com ([2607:f8b0:400e:c05::234]:34269) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cAvYW-0000nA-P7 for bug-coreutils@gnu.org; Sun, 27 Nov 2016 04:15:28 -0500 Received: by mail-pg0-x234.google.com with SMTP id x23so45388614pgx.1 for ; Sun, 27 Nov 2016 01:15:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:content-transfer-encoding:subject:message-id:date:to :mime-version; bh=NtI80nQmI3RxIjvLc8LRRHSciGhfQhhSgIwgnE4HQ1w=; b=bNtnbGglekMKTLDBGyYwB5Cb0E3ixK0TNQu5E4lc9GMQm3+UV2xJ+iEpB9JpeRNDpO 2SaFBDCOfX26FuAea/9CNqLlqX8ZGgZzSlIiHuXWKqPw6fIWuJ2EwPgelCdu+HGMWgxp tm1qbpKw1J0BZDM+pfoaU3BAMv6POw7xo3rQ4HCKO1EqFXftrt5lIFMAY8f1sEKJCGcg f8eE4m29Tcrew6TtyFcYf9oCZLLtSA+9lBJEW3pUf3xEsR9a2mf2tOeo+YqSJyUlGzAm Qnc7KSAb8WDzgZx3mkd/YAwBGDnImKNvgPs0mKts+yM4q5s4Qh+aeasJjy75dcWLvRwb z+aQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:content-transfer-encoding:subject :message-id:date:to:mime-version; bh=NtI80nQmI3RxIjvLc8LRRHSciGhfQhhSgIwgnE4HQ1w=; b=Dn2YWnaLZWEZpL3OrOXDAIjwHkanWmrNig+NO//8vI788hmq1sfoZzRBlZxwjtQOhI QVJW8oj/0aEPUqkrPBvjb9Kr1qYg/AINSLXc7otJKfKuXlDWyPP3mMbL2+PPqEmPA+tf G8dtQfctKhNl61Ma4YvecmWfsKTekPh04jqdbOu2eF7JY/wBX7pgG5YTUaXr4uFXI3bA RkWw7Q6VPCNJS+JCPCPSSTKoMT6HTfWCVz6fZEGKF59VohAGxsBsuUzAUgL6b9Wk7fU0 YQeTjgVPJVqD774BMVPvc1ufZSvA+5xXqS2FaY+yiR+BJ5y6thz06uiUDAJe3cW7by1c UJEg== X-Gm-Message-State: AKaTC03OxUOojQ8yxheTx2itmuxDYpoex86T7iKm9dgFuDkOukhP48x8OhHfcu5/QEPR5w== X-Received: by 10.99.21.65 with SMTP id 1mr29294566pgv.163.1480238127293; Sun, 27 Nov 2016 01:15:27 -0800 (PST) Received: from [192.168.0.129] ([116.87.35.237]) by smtp.gmail.com with ESMTPSA id q20sm61355911pgn.39.2016.11.27.01.15.25 for (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 27 Nov 2016 01:15:26 -0800 (PST) From: =?utf-8?Q?Marcel_B=C3=B6hme?= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Bugs in TAC and TAIL for closed stdin Message-Id: <889D265B-F956-4FA6-8114-0BB0DA2FC234@gmail.com> Date: Sun, 27 Nov 2016 17:15:24 +0800 To: bug-coreutils@gnu.org Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) X-Mailer: Apple Mail (2.3124) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) Dear all, During fuzzing, we found one use-after-free in tac and one = invalid-loading-of-value in tail. Interestingly, these errors can be observed only when stdin is = externally closed but internally expected to be open. The bugs were found by AFLFast, a fork of AFL.=20 The bug in tac was also found by Klee. Thanks again also to Van-Thuan Pham. The following execution crashes TAC in trunk. For the same execution of = preinstalled version 8.21 on Ubuntu x86_64, valgrind flags a few invalid = reads of size 8. There is no problem in version 6.10: $ ./tac - - <&- ./tac: 'standard input': read error: Bad file descriptor =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D53813=3D=3DERROR: AddressSanitizer: heap-use-after-free on address = 0x61600000f990 at pc 0x00000040e127 bp 0x7ffefd0f76e0 sp 0x7ffefd0f76d8 READ of size 8 at 0x61600000f990 thread T0 #0 0x40e126 in rpl_fseeko ../lib/fseeko.c:51 #1 0x4032ac in temp_stream ../src/tac.c:480 #2 0x4032ac in copy_to_temp ../src/tac.c:504 #3 0x4032ac in tac_nonseekable ../src/tac.c:553 #4 0x4032ac in tac_file ../src/tac.c:595 #5 0x4032ac in main ../src/tac.c:701 #6 0x7f135e464f44 in __libc_start_main = (/lib/x86_64-linux-gnu/libc.so.6+0x21f44) #7 0x404779 = (/home/ubuntu/subjects/coreutils/obj-gcov/src/tac+0x404779) 0x61600000f990 is located 16 bytes inside of 568-byte region = [0x61600000f980,0x61600000fbb8) freed by thread T0 here: #0 0x7f135f5e1090 in __interceptor_free = (/usr/lib/x86_64-linux-gnu/libasan.so.3+0xc2090) #1 0x7f135e4b0a24 in _IO_fclose = (/lib/x86_64-linux-gnu/libc.so.6+0x6da24) previously allocated by thread T0 here: #0 0x7f135f5e13a8 in __interceptor_malloc = (/usr/lib/x86_64-linux-gnu/libasan.so.3+0xc23a8) #1 0x7f135e4b0c81 in fdopen = (/lib/x86_64-linux-gnu/libc.so.6+0x6dc81) SUMMARY: AddressSanitizer: heap-use-after-free ../lib/fseeko.c:51 in = rpl_fseeko =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D The following execution of TAIL in trunk is flagged by UBSAN. $ tail -f <&- tail.c:2220:18: runtime error: load of value 190, which is not a valid = value for type =E2=80=98_Bool' For trunk version, version 8.21, and version 6.10 on Ubuntu x86_64, = valgrind reports: =3D=3D28236=3D=3D Conditional jump or move depends on uninitialised = value(s) =3D=3D28236=3D=3D at 0x405941: ignore_fifo_and_pipe (tail.c:2220) =3D=3D28236=3D=3D by 0x405941: main (tail.c:2334) Best regards, - Marcel From debbugs-submit-bounces@debbugs.gnu.org Sun Nov 27 07:13:15 2016 Received: (at 25041-done) by debbugs.gnu.org; 27 Nov 2016 12:13:15 +0000 Received: from localhost ([127.0.0.1]:42921 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cAyKZ-0000x3-09 for submit@debbugs.gnu.org; Sun, 27 Nov 2016 07:13:15 -0500 Received: from mail.magicbluesmoke.com ([82.195.144.49]:40646) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cAyKX-0000wv-9R for 25041-done@debbugs.gnu.org; Sun, 27 Nov 2016 07:13:13 -0500 Received: from [192.168.1.80] (unknown [109.76.227.113]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.magicbluesmoke.com (Postfix) with ESMTPSA id DECD220C; Sun, 27 Nov 2016 12:13:11 +0000 (GMT) Subject: Re: bug#25041: Bugs in TAC and TAIL for closed stdin To: =?UTF-8?Q?Marcel_B=c3=b6hme?= , 25041-done@debbugs.gnu.org References: <889D265B-F956-4FA6-8114-0BB0DA2FC234@gmail.com> From: =?UTF-8?Q?P=c3=a1draig_Brady?= Message-ID: <681320ee-a65a-a514-c403-8112e4ea2294@draigBrady.com> Date: Sun, 27 Nov 2016 12:13:11 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <889D265B-F956-4FA6-8114-0BB0DA2FC234@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 25041-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On 27/11/16 09:15, Marcel Böhme wrote: > Dear all, > > During fuzzing, we found one use-after-free in tac and one invalid-loading-of-value in tail. > Interestingly, these errors can be observed only when stdin is externally closed but internally expected to be open. > > The bugs were found by AFLFast, a fork of AFL. > The bug in tac was also found by Klee. > Thanks again also to Van-Thuan Pham. > > The following execution crashes TAC in trunk. For the same execution of preinstalled version 8.21 on Ubuntu x86_64, valgrind flags a few invalid reads of size 8. There is no problem in version 6.10: > > $ ./tac - - <&- > ./tac: 'standard input': read error: Bad file descriptor > ================================================================= > ==53813==ERROR: AddressSanitizer: heap-use-after-free on address 0x61600000f990 at pc 0x00000040e127 bp 0x7ffefd0f76e0 sp 0x7ffefd0f76d8 > READ of size 8 at 0x61600000f990 thread T0 > #0 0x40e126 in rpl_fseeko ../lib/fseeko.c:51 > #1 0x4032ac in temp_stream ../src/tac.c:480 > #2 0x4032ac in copy_to_temp ../src/tac.c:504 > #3 0x4032ac in tac_nonseekable ../src/tac.c:553 > #4 0x4032ac in tac_file ../src/tac.c:595 > #5 0x4032ac in main ../src/tac.c:701 > #6 0x7f135e464f44 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21f44) > #7 0x404779 (/home/ubuntu/subjects/coreutils/obj-gcov/src/tac+0x404779) > > 0x61600000f990 is located 16 bytes inside of 568-byte region [0x61600000f980,0x61600000fbb8) > freed by thread T0 here: > #0 0x7f135f5e1090 in __interceptor_free (/usr/lib/x86_64-linux-gnu/libasan.so.3+0xc2090) > #1 0x7f135e4b0a24 in _IO_fclose (/lib/x86_64-linux-gnu/libc.so.6+0x6da24) > > previously allocated by thread T0 here: > #0 0x7f135f5e13a8 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.3+0xc23a8) > #1 0x7f135e4b0c81 in fdopen (/lib/x86_64-linux-gnu/libc.so.6+0x6dc81) > > SUMMARY: AddressSanitizer: heap-use-after-free ../lib/fseeko.c:51 in rpl_fseeko > ================================================================= Oh right, we're operating on a closed stream here. I'll fix that up. > The following execution of TAIL in trunk is flagged by UBSAN. > $ tail -f <&- > tail.c:2220:18: runtime error: load of value 190, which is not a valid value for type ‘_Bool' Right we need to init f->ignore in more cases. I confirmed this no longer triggers the issue: diff --git a/src/tail.c b/src/tail.c index 5c75be0..3d83550 100644 --- a/src/tail.c +++ b/src/tail.c @@ -1940,8 +1940,6 @@ tail_file (struct File_spec *f, uintmax_t n_units) ok = false; f->errnum = -1; f->tailable = false; - f->ignore = ! (reopen_inaccessible_files - && follow_mode == Follow_name); error (0, 0, _("%s: cannot follow end of this type of file%s"), quotef (pretty_name (f)), f->ignore ? _("; giving up on this name") : ""); @@ -1949,6 +1947,8 @@ tail_file (struct File_spec *f, uintmax_t n_units) if (!ok) { + f->ignore = ! (reopen_inaccessible_files + && follow_mode == Follow_name); close_fd (fd, pretty_name (f)); f->fd = -1; } thanks! Pádraig From debbugs-submit-bounces@debbugs.gnu.org Sun Nov 27 10:40:42 2016 Received: (at 25041) by debbugs.gnu.org; 27 Nov 2016 15:40:43 +0000 Received: from localhost ([127.0.0.1]:43715 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cB1ZK-000124-K4 for submit@debbugs.gnu.org; Sun, 27 Nov 2016 10:40:42 -0500 Received: from mail.magicbluesmoke.com ([82.195.144.49]:41496) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cB1ZJ-00011v-1a for 25041@debbugs.gnu.org; Sun, 27 Nov 2016 10:40:41 -0500 Received: from [192.168.1.80] (unknown [109.76.227.113]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.magicbluesmoke.com (Postfix) with ESMTPSA id EB35120C; Sun, 27 Nov 2016 15:40:38 +0000 (GMT) Subject: Re: bug#25041: Bugs in TAC and TAIL for closed stdin To: =?UTF-8?Q?Marcel_B=c3=b6hme?= , 25041@debbugs.gnu.org References: <889D265B-F956-4FA6-8114-0BB0DA2FC234@gmail.com> <681320ee-a65a-a514-c403-8112e4ea2294@draigBrady.com> From: =?UTF-8?Q?P=c3=a1draig_Brady?= Message-ID: Date: Sun, 27 Nov 2016 15:40:37 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <681320ee-a65a-a514-c403-8112e4ea2294@draigBrady.com> Content-Type: multipart/mixed; boundary="------------89412ED52EB80E4C3BFDCBA6" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 25041 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) This is a multi-part message in MIME format. --------------89412ED52EB80E4C3BFDCBA6 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit I'll push the attached later thanks again, Pádraiag --------------89412ED52EB80E4C3BFDCBA6 Content-Type: text/x-patch; name="bug-25041.patch" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="bug-25041.patch" >From a31edf2aab384bfd33a6f0ab123d688939c4ddf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= Date: Sun, 27 Nov 2016 13:00:35 +0000 Subject: [PATCH 1/2] 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 --- src/tail.c | 4 ++-- tests/tail-2/follow-stdin.sh | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/tail.c b/src/tail.c index 5c75be0..3d83550 100644 --- a/src/tail.c +++ b/src/tail.c @@ -1940,8 +1940,6 @@ tail_file (struct File_spec *f, uintmax_t n_units) ok = false; f->errnum = -1; f->tailable = false; - f->ignore = ! (reopen_inaccessible_files - && follow_mode == Follow_name); error (0, 0, _("%s: cannot follow end of this type of file%s"), quotef (pretty_name (f)), f->ignore ? _("; giving up on this name") : ""); @@ -1949,6 +1947,8 @@ tail_file (struct File_spec *f, uintmax_t n_units) if (!ok) { + f->ignore = ! (reopen_inaccessible_files + && follow_mode == Follow_name); close_fd (fd, pretty_name (f)); f->fd = -1; } diff --git a/tests/tail-2/follow-stdin.sh b/tests/tail-2/follow-stdin.sh index a2f1804..3d51f60 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 -- 2.5.5 >From 8fc0d1d68b37f67adad8ecc08b3875425130fcb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= Date: Sun, 27 Nov 2016 15:09:53 +0000 Subject: [PATCH 2/2] tac: fix mem corruption when failing to read non seekable inputs This was detected with ASAN, but can also be seen without ASAN with: $ tac - - <&- tac: standard input: read error: Bad file descriptor *** Error in `tac': malloc(): memory corruption: 0x... * src/tac.c (copy_to_temp): Don't close our output stream on error; including input errors. * tests/misc/tac-2-nonseekable.sh: Add a test case. Fixes http://bugs.gnu.org/25041 --- src/tac.c | 10 +++------- tests/misc/tac-2-nonseekable.sh | 3 +++ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/tac.c b/src/tac.c index 2e820fa..e9363b1 100644 --- a/src/tac.c +++ b/src/tac.c @@ -512,13 +512,13 @@ copy_to_temp (FILE **g_tmp, char **g_tempfile, int input_fd, char const *file) if (bytes_read == SAFE_READ_ERROR) { error (0, errno, _("%s: read error"), quotef (file)); - goto Fail; + return -1; } if (fwrite (G_buffer, 1, bytes_read, fp) != bytes_read) { error (0, errno, _("%s: write error"), quotef (file_name)); - goto Fail; + return -1; } /* Implicitly <= OFF_T_MAX due to preceding fwrite(), @@ -530,16 +530,12 @@ copy_to_temp (FILE **g_tmp, char **g_tempfile, int input_fd, char const *file) if (fflush (fp) != 0) { error (0, errno, _("%s: write error"), quotef (file_name)); - goto Fail; + return -1; } *g_tmp = fp; *g_tempfile = file_name; return bytes_copied; - - Fail: - fclose (fp); - return -1; } /* Copy INPUT_FD to a temporary, then tac that file. diff --git a/tests/misc/tac-2-nonseekable.sh b/tests/misc/tac-2-nonseekable.sh index 47e7849..08b35b3 100755 --- a/tests/misc/tac-2-nonseekable.sh +++ b/tests/misc/tac-2-nonseekable.sh @@ -36,4 +36,7 @@ for file in /proc/version /sys/kernel/profiling; do fi done +# This failed due to heap corruption before coreutils 8.26 +returns_ 1 tac - - <&- 2>err || fail=1 + Exit $fail -- 2.5.5 --------------89412ED52EB80E4C3BFDCBA6-- From debbugs-submit-bounces@debbugs.gnu.org Sun Nov 27 10:51:56 2016 Received: (at 25041) by debbugs.gnu.org; 27 Nov 2016 15:51:56 +0000 Received: from localhost ([127.0.0.1]:43719 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cB1kB-0001IX-Q3 for submit@debbugs.gnu.org; Sun, 27 Nov 2016 10:51:55 -0500 Received: from mail-io0-f195.google.com ([209.85.223.195]:35521) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cB1kA-0001IL-62 for 25041@debbugs.gnu.org; Sun, 27 Nov 2016 10:51:54 -0500 Received: by mail-io0-f195.google.com with SMTP id h133so18085194ioe.2 for <25041@debbugs.gnu.org>; Sun, 27 Nov 2016 07:51:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-transfer-encoding; bh=WvE5JB9OJjpSnr8ihuUzEbuqj1LiwQhK/Sog/0/jP2o=; b=jhU2ZiWgJV1UjktPFhRra7Xgthy5IMe37cNUa2UEcq5A0cREpZrkS1rTEMZhXdfw9u YVZX8ekF3k8Xh8LRGVw4ukOeh3dNfBHZkEmAnlKbVfujZDIYSMMKI9hKHDdYSQGqvbEc KktZcDcclnHNMeukMsHJllZ2DrzbXmjILHBx3ZO4gDD0916vRhEyqczLZH9R9bh6YkEr lT8ybPvqDk3ilUNz5EzacssC7zAZH/oVbDYGzX4WnPlZByp+vGvnfDxvghGzYxN2ZyiC nh5sj6yaVLx6oUjz7uTHGH2F9mYc8uxVPeBOqfqtmGBkJdAW0TsmsX5HeZqaLyaVK4uy hMcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc:content-transfer-encoding; bh=WvE5JB9OJjpSnr8ihuUzEbuqj1LiwQhK/Sog/0/jP2o=; b=UIr2fHfI9crAzz0sxP0G7XHHqOVYMYCp2yKT/fTd+ORFV60Fpq7pcclHo0DzwD+Fo2 j40QZCK2c6FKAKSftTo/fsSaN3MTrnu3TFZCB5mona5k1HeNANmv99O59uiuF4PpoGmd 7IAioRrFd5hSyr9p8367l/ghIL5z5Yu9C2iAX9s/i8hsZek/yDvWX66UNsOHknhLWnOT Y9KlK3xfUpCIHz2hxPi95K0QiqW9plQBMiYrKrPFxExjZjZ7Lo03IpoN7908QMJKnehR FKMtvPIM3ZBp8VkU+ZSBZZxCPjCaDIWMb/xHkdbYU5j3fdZHNSAhONVz3GI6mxmJm34n kXIg== X-Gm-Message-State: AKaTC02gRtKsBucrx6HAVjybp8bfPzXsAJCS+IzCgEQcTmoDThpSfpJVXGPJcsBjp3kcoOTm4YfQqeRNm3p17w== X-Received: by 10.36.93.137 with SMTP id w131mr14663577ita.97.1480261908574; Sun, 27 Nov 2016 07:51:48 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.146.66 with HTTP; Sun, 27 Nov 2016 07:51:27 -0800 (PST) In-Reply-To: References: <889D265B-F956-4FA6-8114-0BB0DA2FC234@gmail.com> <681320ee-a65a-a514-c403-8112e4ea2294@draigBrady.com> From: Jim Meyering Date: Sun, 27 Nov 2016 07:51:27 -0800 X-Google-Sender-Auth: xqLS_sTlj5I9sexleFTzMOJ-Ba0 Message-ID: Subject: Re: bug#25041: Bugs in TAC and TAIL for closed stdin To: =?UTF-8?Q?P=C3=A1draig_Brady?= Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 25041 Cc: 25041@debbugs.gnu.org, =?UTF-8?Q?Marcel_B=C3=B6hme?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On Sun, Nov 27, 2016 at 7:40 AM, P=C3=A1draig Brady wrot= e: > I'll push the attached later Thanks to both of you. That patch looks fine, modulo a formatting nit: the second line is indented one space too far: + f->ignore =3D ! (reopen_inaccessible_files + && follow_mode =3D=3D Follow_name); From debbugs-submit-bounces@debbugs.gnu.org Sun Nov 27 16:22:54 2016 Received: (at 25041) by debbugs.gnu.org; 27 Nov 2016 21:22:54 +0000 Received: from localhost ([127.0.0.1]:43930 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cB6uT-0004A2-SZ for submit@debbugs.gnu.org; Sun, 27 Nov 2016 16:22:54 -0500 Received: from mail.magicbluesmoke.com ([82.195.144.49]:42928) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cB6uS-00049r-5u for 25041@debbugs.gnu.org; Sun, 27 Nov 2016 16:22:52 -0500 Received: from [192.168.1.80] (unknown [109.76.227.113]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.magicbluesmoke.com (Postfix) with ESMTPSA id 88DD294A7; Sun, 27 Nov 2016 21:22:48 +0000 (GMT) Subject: Re: bug#25041: Bugs in TAC and TAIL for closed stdin To: Jim Meyering References: <889D265B-F956-4FA6-8114-0BB0DA2FC234@gmail.com> <681320ee-a65a-a514-c403-8112e4ea2294@draigBrady.com> From: =?UTF-8?Q?P=c3=a1draig_Brady?= Message-ID: Date: Sun, 27 Nov 2016 21:22:48 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 25041 Cc: 25041@debbugs.gnu.org, =?UTF-8?Q?Marcel_B=c3=b6hme?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On 27/11/16 15:51, Jim Meyering wrote: > On Sun, Nov 27, 2016 at 7:40 AM, Pádraig Brady wrote: >> I'll push the attached later > > Thanks to both of you. > > That patch looks fine, modulo a formatting nit: the second line is > indented one space too far: > > + f->ignore = ! (reopen_inaccessible_files > + && follow_mode == Follow_name); > Done. Also we should probably clear any errors such as ENOSPC from the stream before reuse for the next input: diff --git a/src/tac.c b/src/tac.c index 2e820fa..c1b6003 100644 --- a/src/tac.c +++ b/src/tac.c @@ -477,6 +477,7 @@ temp_stream (FILE **fp, char **file_name) } else { + clearerr (tmp_fp); if (fseeko (tmp_fp, 0, SEEK_SET) < 0 || ftruncate (fileno (tmp_fp), 0) < 0) { cheers, Pádraig From unknown Fri Jun 20 07:29:04 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Mon, 26 Dec 2016 12:24:03 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator