summaryrefslogtreecommitdiff
path: root/libarchive/archive_read.c
diff options
context:
space:
mode:
authorDmitry Torokhov <dtor@chromium.org>2019-06-25 10:09:44 -0700
committerDmitry Torokhov <dtor@chromium.org>2019-06-26 10:29:52 -0700
commitaa48bfac0f4ede8a6a4dfa545ad91684b41a9285 (patch)
tree67a6222651baa1fb2a9653e4d0b6d356ca081483 /libarchive/archive_read.c
parenta163558c388bb2ccedef683e8031c11193e6875c (diff)
downloadlibarchive-aa48bfac0f4ede8a6a4dfa545ad91684b41a9285.tar.gz
archive_read: fix handling of sparse files
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
Diffstat (limited to 'libarchive/archive_read.c')
-rw-r--r--libarchive/archive_read.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/libarchive/archive_read.c b/libarchive/archive_read.c
index de964f25..58726011 100644
--- a/libarchive/archive_read.c
+++ b/libarchive/archive_read.c
@@ -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;