diff options
author | lloyd <[email protected]> | 2011-02-18 18:55:53 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2011-02-18 18:55:53 +0000 |
commit | 17d1cb0d352477bba9ec4e8a237b1cff21cb5d96 (patch) | |
tree | 2dc6f767834d7355a85961a9cf01d9d4a4c36897 /src | |
parent | debeb26a1c2615d7dd61bce535f22133eec38b17 (diff) |
Fix PR 142: the zlib filters were not updated in 1.9.11 to use zeroise
instead of clear, so the buffer ended up having size zero, which meant
the compression library could never actually do anything, and we would
infinite loop.
Also add buffer clearing to bzip2, which was missing it entirely.
Diffstat (limited to 'src')
-rw-r--r-- | src/filters/bzip2/bzip2.cpp | 24 | ||||
-rw-r--r-- | src/filters/zlib/zlib.cpp | 16 |
2 files changed, 25 insertions, 15 deletions
diff --git a/src/filters/bzip2/bzip2.cpp b/src/filters/bzip2/bzip2.cpp index b166017c3..a291c1173 100644 --- a/src/filters/bzip2/bzip2.cpp +++ b/src/filters/bzip2/bzip2.cpp @@ -168,10 +168,14 @@ void Bzip_Compression::flush() */ void Bzip_Compression::clear() { - if(!bz) return; - BZ2_bzCompressEnd(&(bz->stream)); - delete bz; - bz = 0; + zeroise(buffer); + + if(bz) + { + BZ2_bzCompressEnd(&(bz->stream)); + delete bz; + bz = 0; + } } /* @@ -278,10 +282,14 @@ void Bzip_Decompression::end_msg() */ void Bzip_Decompression::clear() { - if(!bz) return; - BZ2_bzDecompressEnd(&(bz->stream)); - delete bz; - bz = 0; + zeroise(buffer); + + if(bz) + { + BZ2_bzDecompressEnd(&(bz->stream)); + delete bz; + bz = 0; + } } } diff --git a/src/filters/zlib/zlib.cpp b/src/filters/zlib/zlib.cpp index 30dee0225..0f88b5558 100644 --- a/src/filters/zlib/zlib.cpp +++ b/src/filters/zlib/zlib.cpp @@ -138,9 +138,11 @@ void Zlib_Compression::end_msg() { zlib->stream.next_out = reinterpret_cast<Bytef*>(buffer.begin()); zlib->stream.avail_out = buffer.size(); + rc = deflate(&(zlib->stream), Z_FINISH); send(buffer.begin(), buffer.size() - zlib->stream.avail_out); } + clear(); } @@ -155,13 +157,13 @@ void Zlib_Compression::flush() while(true) { zlib->stream.avail_out = buffer.size(); - zlib->stream.next_out = reinterpret_cast<Bytef*>(buffer.begin()); - deflate(&(zlib->stream), Z_FULL_FLUSH); send(buffer.begin(), buffer.size() - zlib->stream.avail_out); - if(zlib->stream.avail_out == buffer.size()) break; + + if(zlib->stream.avail_out == buffer.size()) + break; } } @@ -170,14 +172,14 @@ void Zlib_Compression::flush() */ void Zlib_Compression::clear() { + zeroise(buffer); + if(zlib) { deflateEnd(&(zlib->stream)); delete zlib; zlib = 0; } - - buffer.clear(); } /* @@ -283,6 +285,8 @@ void Zlib_Decompression::end_msg() */ void Zlib_Decompression::clear() { + zeroise(buffer); + no_writes = true; if(zlib) @@ -291,8 +295,6 @@ void Zlib_Decompression::clear() delete zlib; zlib = 0; } - - buffer.clear(); } } |