]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
archive_read: fix handling of sparse files
authorDmitry Torokhov <dtor@chromium.org>
Tue, 25 Jun 2019 17:09:44 +0000 (10:09 -0700)
committerDmitry Torokhov <dtor@chromium.org>
Wed, 26 Jun 2019 17:29:52 +0000 (10:29 -0700)
If a file ends with a sparse "hole" that is larger than buffer supplied
to archive_read(), then archive_read() will return prematurely because
archive_read_data_block() will return ARHCIVE_EOF as there is no more
"real" data. We can fix that by not trying to refill data buffer until
we exhaust the hole range.

Fixes libarchive#1194

libarchive/archive_read.c

index de964f2532843340f4cf25cffa212a3780bc852e..5872601101ba60dcd95c1fe3d210743b01dad98c 100644 (file)
@@ -844,7 +844,8 @@ archive_read_data(struct archive *_a, void *buff, size_t s)
        dest = (char *)buff;
 
        while (s > 0) {
-               if (a->read_data_remaining == 0) {
+               if (a->read_data_offset == a->read_data_output_offset &&
+                   a->read_data_remaining == 0) {
                        read_buf = a->read_data_block;
                        a->read_data_is_posix_read = 1;
                        a->read_data_requested = s;