From: Alexey Spiridonov Date: Mon, 2 Feb 2015 03:26:26 +0000 (-0800) Subject: Do not request 0-length skips; sanity-check return. X-Git-Tag: v3.1.900a~145^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=afcc3e49ad6689288245d1540ac8a1d8de27a921;p=thirdparty%2Flibarchive.git 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. --- 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) {