From: Dmitry Torokhov Date: Tue, 25 Jun 2019 17:09:44 +0000 (-0700) Subject: archive_read: fix handling of sparse files X-Git-Tag: v3.4.1~50^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aa48bfac0f4ede8a6a4dfa545ad91684b41a9285;p=thirdparty%2Flibarchive.git 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 --- diff --git a/libarchive/archive_read.c b/libarchive/archive_read.c index de964f253..587260110 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;