Ver código fonte

* 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

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…

David Kalnischkies 14 anos atrás
pai
commit
65c72a4b84
2 arquivos alterados com 8 adições e 3 exclusões
  1. 3 1
      apt-pkg/contrib/fileutl.cc
  2. 5 2
      debian/changelog

+ 3 - 1
apt-pkg/contrib/fileutl.cc

@@ -1347,6 +1347,7 @@ unsigned long long FileFd::Size()
    // gzopen in "direct" mode as well
    // gzopen in "direct" mode as well
    else if (d->gz && !gzdirect(d->gz) && size > 0)
    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
        /* unfortunately zlib.h doesn't provide a gzsize(), so we have to do
 	* this ourselves; the original (uncompressed) file size is the last 32
 	* this ourselves; the original (uncompressed) file size is the last 32
 	* bits of the file */
 	* bits of the file */
@@ -1364,8 +1365,9 @@ unsigned long long FileFd::Size()
        size = tmp_size;
        size = tmp_size;
 #endif
 #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 _error->Errno("lseek","Unable to seek in gzipped file");
+
        return size;
        return size;
    }
    }
 #endif
 #endif

+ 5 - 2
debian/changelog

@@ -9,12 +9,15 @@ apt (0.8.16~exp10) UNRELEASED; urgency=low
   * apt-pkg/deb/dpkgpm.cc:
   * apt-pkg/deb/dpkgpm.cc:
     - check if dpkg supports multiarch with --assert-multi-arch
     - check if dpkg supports multiarch with --assert-multi-arch
       and if it does be always explicit about the architecture
       and if it does be always explicit about the architecture
+  * 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
 
 
   [ Michael Vogt ]
   [ Michael Vogt ]
-  * apt-pkg/contrib/fileutils.h:
+  * apt-pkg/contrib/fileutl.h:
     - fix segfault from python-apt testsuite
     - fix segfault from python-apt testsuite
 
 
- -- David Kalnischkies <kalnischkies@gmail.com>  Fri, 13 Jan 2012 17:29:07 +0100
+ -- David Kalnischkies <kalnischkies@gmail.com>  Wed, 18 Jan 2012 00:47:54 +0100
 
 
 apt (0.8.16~exp9) experimental; urgency=low
 apt (0.8.16~exp9) experimental; urgency=low