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