From 65c72a4b84273bf8063076bd74861b5931c2b8a5 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 18 Jan 2012 00:51:03 +0100 Subject: * apt-pkg/contrib/fileutl.h: - store the offset in the internal fd before calculate size of the zlib-handled file to jump back to this place again MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It jumped back to the position of the content - which is wrong as the internal fd is compressed and even reseting to the beginning of the file doesn't work as zlib uses an internal buffer, so while we might haven't read anything yet zlib might have done so already… --- apt-pkg/contrib/fileutl.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'apt-pkg/contrib') diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index 2bbf3a1b1..28898fc34 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -1347,6 +1347,7 @@ unsigned long long FileFd::Size() // gzopen in "direct" mode as well else if (d->gz && !gzdirect(d->gz) && size > 0) { + off_t const oldPos = lseek(iFd,0,SEEK_CUR); /* unfortunately zlib.h doesn't provide a gzsize(), so we have to do * this ourselves; the original (uncompressed) file size is the last 32 * bits of the file */ @@ -1364,8 +1365,9 @@ unsigned long long FileFd::Size() size = tmp_size; #endif - if (lseek(iFd, d->seekpos, SEEK_SET) < 0) + if (lseek(iFd, oldPos, SEEK_SET) < 0) return _error->Errno("lseek","Unable to seek in gzipped file"); + return size; } #endif -- cgit v1.2.3