]> localhost Git - libzipper.git/commitdiff
Fixed an issue in deflate that would cause corruption or fail v1.0.2
authorMichael McMaster <email@michaelmcmaster.name>
Wed, 7 Sep 2011 20:04:11 +0000 (06:04 +1000)
committerMichael McMaster <email@michaelmcmaster.name>
Wed, 7 Sep 2011 20:04:11 +0000 (06:04 +1000)
extract valid files.

NEWS
VERSION
autodeb.sh
debian/changelog
deflate.cc

diff --git a/NEWS b/NEWS
index 967e5e13aff2cc409202d635bc55f3e33bf0648e..85a043f2d4c0b37349d7fa69fee80d27ebebcfdd 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,7 @@
+2011-09-07  Version 1.0.2
+       - Fixed a bug in deflate, which caused it to exit prematurely and
+       report valid files as corrupt.
+
 2011-05-27  Version 1.0.1
        - Removed private classes from doxygen output
        - Added the zipper utility executable
diff --git a/VERSION b/VERSION
index 7dea76edb3dc51b6e5e8223e9f941a35c1e364d6..6d7de6e6abef13b18021a3591debc53ac00616d4 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.0.1
+1.0.2
index 1dc67d662b0c90a08b3c43464b9988d481077957..b5ee069873ef770c1314984d8fbf967cec45e6cb 100755 (executable)
@@ -33,10 +33,10 @@ cp -a ${SRC}/debian libzipper-${VERSION}
 cd libzipper-${VERSION}
 dpkg-buildpackage -rfakeroot
 
-if ! lintian --color auto --fail-on-warnings -i ${BUILD}/libzipper_1.0.1-1.dsc; then
+if ! lintian --color auto --fail-on-warnings -i ${BUILD}/libzipper_1.0.2-1.dsc; then
        echo "Build failed"
        exit 1;
-elif ! lintian --color auto --fail-on-warnings -i ${BUILD}/libzipper_1.0.1-1_amd64.changes; then
+elif ! lintian --color auto --fail-on-warnings -i ${BUILD}/libzipper_1.0.2-1_amd64.changes; then
        echo "Build failed"
        exit 1;
 else
index 92fa1ba843a3c5eda6fcd813c28134b61681726b..1d78d64a01ad0e6fad7ec47523d4ec2ccdb21a87 100644 (file)
@@ -1,3 +1,10 @@
+libzipper (1.0.2-1) unstable; urgency=low
+
+  * Fixed a bug in the deflate methods, which would report corrupt data for
+    valid zip/gzip files.
+
+ -- Michael McMaster <michael@codesrc.com>  Wed, 07 Sep 2011 21:59:18 +1000
+
 libzipper (1.0.1-1) unstable; urgency=low
 
   * Initial release. (Closes: #628118)
index 3fff1609c4d25ac864e2bb67c67c8252e1c0a1c4..986f6d13b6a04165927d3ed7cb949b20350611f0 100644 (file)
@@ -94,14 +94,15 @@ zipper::deflate(
        DeflateDeleter deleter(&stream);
        stream.next_in = NULL;
        stream.avail_in = 0;
+       bool finished(false);
 
        zsize_t pos(0);
        zsize_t end(reader.getSize());
        crc = crc32(0, NULL, 0);
 
-       while (pos < end)
+       while (!finished)
        {
-               if (stream.avail_in == 0)
+               if ((stream.avail_in == 0) && (pos < end))
                {
                        stream.avail_in =
                                std::min(zsize_t(ChunkSize), end - pos);
@@ -116,6 +117,7 @@ zipper::deflate(
                stream.next_out = reinterpret_cast<Bytef*>(&outChunk);
                stream.avail_out = sizeof(outChunk);
 
+               finished = false;
                zlibErr = deflate(&stream, (pos < end) ? Z_NO_FLUSH : Z_FINISH);
 
                if (zlibErr == Z_STREAM_END)
@@ -125,6 +127,7 @@ zipper::deflate(
                                assert(!"zlib buffer unexpectedly empty");
                                std::terminate();
                        }
+                       finished = true;
                }
                else if (zlibErr != Z_OK)
                {
@@ -164,11 +167,15 @@ zipper::inflate(
 
        zsize_t pos(readOffset);
        crc = crc32(0, NULL, 0);
-       while (pos < readEnd)
+       while (!finished)
        {
                if (stream.avail_in == 0)
                {
                        stream.avail_in = std::min(zsize_t(ChunkSize), readEnd - pos);
+                       if (stream.avail_in == 0)
+                       {
+                               break;
+                       }
                        reader->readData(pos, stream.avail_in, &inChunk[0]);
                        stream.next_in = reinterpret_cast<Bytef*>(&inChunk);
                        pos += stream.avail_in;
@@ -193,8 +200,6 @@ zipper::inflate(
                writer.writeData(writeOffset, bytesToWrite, &outChunk[0]);
                writeOffset += bytesToWrite;
                crc = crc32(crc, &outChunk[0], bytesToWrite);
-
-               if (finished) break;
        }
        if (!finished)
        {