From: Tim Kientzle Date: Tue, 8 Sep 2009 03:47:47 +0000 (-0400) Subject: Reading zip archives failed if you only gave X-Git-Tag: v2.8.0~367 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fc5969cde6dd6160be7e8648aecbd8017fadffeb;p=thirdparty%2Flibarchive.git Reading zip archives failed if you only gave archive_read_support_format_zip() because of a bug in how the read-ahead logic handled read(0) requests. Change the compat_zip test to exercise this case and fix the underlying bug. Thanks to: Ed Schouten and Roman Divacky SVN-Revision: 1441 --- diff --git a/libarchive/archive_read.c b/libarchive/archive_read.c index c72e27d02..ac4c89fba 100644 --- a/libarchive/archive_read.c +++ b/libarchive/archive_read.c @@ -961,9 +961,12 @@ __archive_read_filter_ahead(struct archive_read_filter *filter, for (;;) { /* - * If we can satisfy from the copy buffer, we're done. + * If we can satisfy from the copy buffer (and the + * copy buffer isn't empty), we're done. In particular, + * note that min == 0 is a perfectly well-defined + * request. */ - if (filter->avail >= min) { + if (filter->avail >= min && filter->avail > 0) { if (avail != NULL) *avail = filter->avail; return (filter->next); diff --git a/libarchive/test/test_compat_zip.c b/libarchive/test/test_compat_zip.c index 5cb84a049..950562c33 100644 --- a/libarchive/test/test_compat_zip.c +++ b/libarchive/test/test_compat_zip.c @@ -36,7 +36,7 @@ test_compat_zip_1(void) assert((a = archive_read_new()) != NULL); assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a)); - assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a)); + assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_zip(a)); extract_reference_file(name); assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, name, 10240));