Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 8 May 2007 13:58:57 GMT
From:      Spencer Minear<minear@securecomputing.com>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   misc/112521: exit code from tar -tf is not non-zero when an error is detected
Message-ID:  <200705081358.l48DwvQ3097134@www.freebsd.org>
Resent-Message-ID: <200705081410.l48EA3Rl086103@freefall.freebsd.org>

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

>Number:         112521
>Category:       misc
>Synopsis:       exit code from tar -tf is not non-zero when an error is detected
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue May 08 14:10:03 GMT 2007
>Closed-Date:
>Last-Modified:
>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:
>Unformatted:



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