diff options
author | kientzle <kientzle@FreeBSD.org> | 2004-06-07 04:32:10 +0000 |
---|---|---|
committer | kientzle <kientzle@FreeBSD.org> | 2004-06-07 04:32:10 +0000 |
commit | a340d81a042427076afd32955d8169b71d2bce25 (patch) | |
tree | b3f15d1ca62cc5052978a852e118cbb4f2306c6d | |
parent | 0769b9f0d649d685716fbd042d363777f72c4127 (diff) | |
download | FreeBSD-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
-rw-r--r-- | lib/libarchive/archive_read_support_format_tar.c | 12 |
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); } |