]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Reading zip archives failed if you only gave
authorTim Kientzle <kientzle@gmail.com>
Tue, 8 Sep 2009 03:47:47 +0000 (23:47 -0400)
committerTim Kientzle <kientzle@gmail.com>
Tue, 8 Sep 2009 03:47:47 +0000 (23:47 -0400)
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

libarchive/archive_read.c
libarchive/test/test_compat_zip.c

index c72e27d02cf97cc7c6552de9ccbab2ab1f2c65f7..ac4c89fba45f8fbc79299383f99e6aa38e44c4fb 100644 (file)
@@ -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);
index 5cb84a049e791db2084a457fb1a192b2d025cb09..950562c33ed2e0c9cf722a2089071e95cdc4722f 100644 (file)
@@ -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));