From dee0ce0cbdf56b773580eb7de0a1eb061bc56f7e Mon Sep 17 00:00:00 2001 From: Tim Kientzle Date: Tue, 29 Dec 2009 05:30:23 +0000 Subject: [PATCH] Catch decompression failures earlier. In particular, this gives immediate feedback if we fail to fork an external decompression program. --- lib/libarchive/archive_read.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/libarchive/archive_read.c b/lib/libarchive/archive_read.c index bef2438e1591..fd56dc607194 100644 --- a/lib/libarchive/archive_read.c +++ b/lib/libarchive/archive_read.c @@ -354,6 +354,7 @@ build_stream(struct archive_read *a) int number_bidders, i, bid, best_bid; struct archive_read_filter_bidder *bidder, *best_bidder; struct archive_read_filter *filter; + ssize_t avail; int r; for (;;) { @@ -392,6 +393,13 @@ build_stream(struct archive_read *a) free(filter); return (r); } + /* Verify the filter by asking it for some data. */ + __archive_read_filter_ahead(filter, 1, &avail); + if (avail < 0) { + /* If the read failed, bail out now. */ + free(filter); + return (avail); + } a->filter = filter; } }