From owner-freebsd-bugs Thu Sep 27 11:40:11 2001 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 7056D37B41E for ; Thu, 27 Sep 2001 11:40:04 -0700 (PDT) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.4/8.11.4) id f8RIe4M85788; Thu, 27 Sep 2001 11:40:04 -0700 (PDT) (envelope-from gnats) Received: from merlot.juniper.net (natint.juniper.net [207.17.136.129]) by hub.freebsd.org (Postfix) with ESMTP id EF5B437B40D for ; Thu, 27 Sep 2001 11:39:32 -0700 (PDT) Received: from sjg-bsd.juniper.net (sjg-bsd.juniper.net [172.17.12.120]) by merlot.juniper.net (8.11.3/8.11.3) with ESMTP id f8RIdQ042045; Thu, 27 Sep 2001 11:39:26 -0700 (PDT) (envelope-from sjg@juniper.net) Received: (from sjg@localhost) by sjg-bsd.juniper.net (8.11.1/8.9.3) id f8RIdQG18276; Thu, 27 Sep 2001 11:39:26 -0700 (PDT) (envelope-from sjg) Message-Id: <200109271839.f8RIdQG18276@sjg-bsd.juniper.net> Date: Thu, 27 Sep 2001 11:39:26 -0700 (PDT) From: Simon Gerraty Reply-To: sjg@juniper.net To: FreeBSD-gnats-submit@freebsd.org Cc: bug-tar@gnu.org X-Send-Pr-Version: 3.2 Subject: gnu/30876: tar ignores complaints from gzip Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >Number: 30876 >Category: gnu >Synopsis: tar ignores complaints from gzip >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Thu Sep 27 11:40:04 PDT 2001 >Closed-Date: >Last-Modified: >Originator: Simon Gerraty >Release: FreeBSD 4.2-RELEASE i386 >Organization: Juniper Networks Inc. >Environment: >Description: The patch below fixes a couple of issues with how tar interacts with its child - gzip. 1. When the child (gzip) exists with a bad status, tar reports it but does not propagate the failure to its caller. This has lead to pkg_add attempting to install corrupted binaries when a gzip fails CRC checks but tar has read the end of archive marker before gzip exits. Tar should never ignore a bad exit status from its child. 2. Tar closes the pipe as soon as it reads the end of archive. It understands that this might result in its child dying due to SIGPIPE and it ignores that condition. However, if the child catches SIGPIPE and just exit's 1, the fix above will result in an unnecessary failure. Tar should read EOF from the child before closing the pipe. --sjg >How-To-Repeat: >Fix: I can't get a connection to anoncvs.freebsd.org, but the following patch applies cleanly to -current. Index: buffer.c =================================================================== retrieving revision 1.1.1.1 diff -u -p -r1.1.1.1 buffer.c --- buffer.c 1997/02/26 02:34:43 1.1.1.1 +++ buffer.c 2001/09/19 16:17:31 @@ -1254,6 +1254,20 @@ close_archive () if (f_verify) verify_volume (); +#ifndef __MSDOS__ + /* + * closing the child's pipe before reading EOF guarantees that it + * will be unhappy - SIGPIPE, or exit 1. + * Either way it can screw us, so play nice. + */ + if (childpid && ar_reading) { + char buf[BUFSIZ]; + + while ((c = read(archive, buf, sizeof(buf))) > 0) + continue; + } +#endif + if ((c = rmtclose (archive)) < 0) msg_perror ("Warning: can't close %s(%d,%d)", ar_files[cur_ar_file], archive, c); @@ -1291,9 +1305,11 @@ close_archive () */ /* Do nothing. */ } - else if (WEXITSTATUS (status)) + else if (WEXITSTATUS (status)) { msg ("child returned status %d", WEXITSTATUS (status)); + exit (EX_BADARCH); + } } } } >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message