Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 27 Sep 2001 11:39:26 -0700 (PDT)
From:      Simon Gerraty <sjg@juniper.net>
To:        FreeBSD-gnats-submit@freebsd.org
Cc:        bug-tar@gnu.org
Subject:   gnu/30876: tar ignores complaints from gzip
Message-ID:  <200109271839.f8RIdQG18276@sjg-bsd.juniper.net>

next in thread | raw e-mail | index | archive | help

>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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200109271839.f8RIdQG18276>