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
This commit is contained in:
kientzle 2004-06-07 04:32:10 +00:00
parent 430214e897
commit 44727e706c

View File

@ -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);
}