From afcc3e49ad6689288245d1540ac8a1d8de27a921 Mon Sep 17 00:00:00 2001 From: Alexey Spiridonov Date: Sun, 1 Feb 2015 19:26:26 -0800 Subject: [PATCH] Do not request 0-length skips; sanity-check return. I noticed that my skip callback was always being invoked with a request of 0. This is a bit wasteful since skip callbacks commonly involve a syscall like lseek(). Also, it seems good to error out when the skip callback is buggy, and claims to skip more than requested. Test Plan: ``` autoreconf -ivf && ./configure && make && make check ``` The same tests fail as before, with the same error messages. If interested, both failure logs are here: https://github.com/snarkmaster/libarchive/commit/00c9751cde6cc888fb844b7a1fcc0f82dbaaedb1 These are on Ubuntu 14.04. --- libarchive/archive_read.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libarchive/archive_read.c b/libarchive/archive_read.c index d649e9aae..2cd9726a6 100644 --- a/libarchive/archive_read.c +++ b/libarchive/archive_read.c @@ -195,10 +195,12 @@ client_skip_proxy(struct archive_read_filter *self, int64_t request) ask = skip_limit; get = (self->archive->client.skipper) (&self->archive->archive, self->data, ask); - if (get == 0) + total += get; + if (get == 0 || get == request) return (total); + if (get > request) + return ARCHIVE_FATAL; request -= get; - total += get; } } else if (self->archive->client.seeker != NULL && request > 64 * 1024) { -- 2.47.2