summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorkientzle <kientzle@FreeBSD.org>2004-06-07 04:32:10 +0000
committerkientzle <kientzle@FreeBSD.org>2004-06-07 04:32:10 +0000
commita340d81a042427076afd32955d8169b71d2bce25 (patch)
treeb3f15d1ca62cc5052978a852e118cbb4f2306c6d /lib
parent0769b9f0d649d685716fbd042d363777f72c4127 (diff)
downloadFreeBSD-src-a340d81a042427076afd32955d8169b71d2bce25.zip
FreeBSD-src-a340d81a042427076afd32955d8169b71d2bce25.tar.gz
Tar bidder should just return a zero bid ("not me!") if
it sees a truncated input the first time it gets called. (In particular, files shorter than 512 bytes cannot be tar archives.) This allows the top-level archive_read_next_header code to generate a proper error message for unrecognized file types. Pointed out by: numerous ports that expect tar to extract non-tar files ;-( Thanks to: Kris Kennaway
Diffstat (limited to 'lib')
-rw-r--r--lib/libarchive/archive_read_support_format_tar.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/libarchive/archive_read_support_format_tar.c b/lib/libarchive/archive_read_support_format_tar.c
index a30562f..a68eb39 100644
--- a/lib/libarchive/archive_read_support_format_tar.c
+++ b/lib/libarchive/archive_read_support_format_tar.c
@@ -209,9 +209,15 @@ archive_read_format_tar_bid(struct archive *a)
return (1);
}
if (bytes_read < 512) {
- if (bid > 0)
- archive_set_error(a, ARCHIVE_ERRNO_FILE_FORMAT,
- "Truncated tar archive");
+ /* If it's a new archive, then just return a zero bid. */
+ if (bid == 0)
+ return (0);
+ /*
+ * If we already know this is a tar archive,
+ * then we have a problem.
+ */
+ archive_set_error(a, ARCHIVE_ERRNO_FILE_FORMAT,
+ "Truncated tar archive");
return (ARCHIVE_FATAL);
}
OpenPOWER on IntegriCloud