| From 2e3e1377163355ea937d01c870e779ea32f1caa7 Mon Sep 17 00:00:00 2001 |
| From: Dmitry Torokhov <dtor@chromium.org> |
| Date: Tue, 25 Jun 2019 10:09:44 -0700 |
| Subject: [PATCH] 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 |
| --- |
| libarchive/archive_read.c | 3 ++- |
| 1 file changed, 2 insertions(+), 1 deletion(-) |
| |
| diff --git a/libarchive/archive_read.c b/libarchive/archive_read.c |
| index 0e56e76e..7548054e 100644 |
| --- a/libarchive/archive_read.c |
| +++ b/libarchive/archive_read.c |
| @@ -835,7 +835,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; |
| -- |
| 2.22.0.410.gd8fdbe21b5-goog |
| |