From nobody@FreeBSD.org  Tue May  8 14:03:57 2007
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id 8A79416A400
	for <freebsd-gnats-submit@FreeBSD.org>; Tue,  8 May 2007 14:03:57 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [69.147.83.33])
	by mx1.freebsd.org (Postfix) with ESMTP id 792C513C45B
	for <freebsd-gnats-submit@FreeBSD.org>; Tue,  8 May 2007 14:03:57 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id l48E3vnF013484
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 8 May 2007 14:03:57 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id l48DwvQ3097134;
	Tue, 8 May 2007 13:58:57 GMT
	(envelope-from nobody)
Message-Id: <200705081358.l48DwvQ3097134@www.freebsd.org>
Date: Tue, 8 May 2007 13:58:57 GMT
From: Spencer Minear<minear@securecomputing.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: exit code from tar -tf is not non-zero when an error is detected
X-Send-Pr-Version: www-3.0

>Number:         112521
>Category:       bin
>Synopsis:       tar(1): exit code from tar -tf is not non-zero when an error is detected
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kientzle
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue May 08 14:10:03 GMT 2007
>Closed-Date:    Tue Sep 18 04:23:42 GMT 2007
>Last-Modified:  Tue Sep 18 04:23:42 GMT 2007
>Originator:     Spencer Minear
>Release:        Seen on FreeBSD 6.0, but appears to still be present in current
>Organization:
Secure Computing Corp
>Environment:
FreeBSD nowind2.scur.com 6.0-RELEASE FreeBSD 6.0-RELEASE 
>Description:
If you run tar -tvf archive_file on an archive that is bad or truncated tar will write an error message like: "tar: (Empty error message)" for a tar file or "tar: Truncated ZIP file body: Inappropriate file type or format" for a ZIP file.  BUT in both cases the exit code after this "error" is 0.  

This appears to be inconsistent with the information in the tar manual page which says that "The tar utility exits 0 on success, and >0 if an error occurs."






>How-To-Repeat:
Use an editor of choice to bugger up or truncate a tarball and use tar to get a listing of contents and check the exit status from the command.

>Fix:
In the usr.bin/tar/read.c file when running in the 't' mode if archive_read_data_skip returns an ARCHIVE_FATAL status wet the bsdtar retgurn_value to 1.

@@ -184,6 +184,7 @@
                        }
                        if (r == ARCHIVE_FATAL) {
                                fprintf(out, "\n");
+                               bsdtar->return_value = 1;
                                bsdtar_warnc(bsdtar, 0, "%s",
                                    archive_error_string(a));
                                break;

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->kientzle 
Responsible-Changed-By: rafan 
Responsible-Changed-When: Tue May 8 14:29:29 UTC 2007 
Responsible-Changed-Why:  
Over to maintainer. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=112521 
State-Changed-From-To: open->patched 
State-Changed-By: kientzle 
State-Changed-When: Tue May 8 15:22:37 UTC 2007 
State-Changed-Why:  
Spencer's patch committed to -CURRENT. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=112521 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: misc/112521: commit references a PR
Date: Tue,  8 May 2007 15:22:29 +0000 (UTC)

 kientzle    2007-05-08 15:22:22 UTC
 
   FreeBSD src repository
 
   Modified files:
     usr.bin/tar          read.c 
   Log:
   Set the program return value non-zero if we enounter
   an error while skipping the body of an entry during
   "tar -t" processing.
   
   Thanks to: Spencer Minear
   PR: misc/112521
   
   Revision  Changes    Path
   1.32      +1 -0      src/usr.bin/tar/read.c
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: patched->closed 
State-Changed-By: kientzle 
State-Changed-When: Tue Sep 18 04:22:50 UTC 2007 
State-Changed-Why:  
This has been MFCed to 6-STABLE. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=112521 
>Unformatted:
