aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/log.txt1
-rw-r--r--src/filters/bzip2/bzip2.cpp24
-rw-r--r--src/filters/zlib/zlib.cpp16
3 files changed, 26 insertions, 15 deletions
diff --git a/doc/log.txt b/doc/log.txt
index 06107928a..d86aba45f 100644
--- a/doc/log.txt
+++ b/doc/log.txt
@@ -2,6 +2,7 @@
* 1.9.14-dev, ????-??-??
- Add support for bcrypt, OpenBSD's password hashing scheme
- Add support for NIST's AES key wrapping algorithm
+ - Fix an infinite loop in zlib filters introduced in 1.9.11 (PR 142)
* 1.9.13, 2011-02-19
- Update Keccak to the round 3 variant
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();
}
}