aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/compression
diff options
context:
space:
mode:
authorlloyd <[email protected]>2015-05-13 03:00:10 +0000
committerlloyd <[email protected]>2015-05-13 03:00:10 +0000
commitcb2b4498d2a0c8a15e2a66aa3c5f0d7ffa4cf058 (patch)
treec002be7e34bd0c6973b9d49f92ee7973c5152e59 /src/lib/compression
parenta1524df3c1b7bee3bfd7cab3309f763b3e9599a7 (diff)
Add tests for compression and SRP.
Fix zlib decompression which was not ignoring Z_BUF_ERROR which is harmless in this context as process is already checking avail_in and avail_out after run returns. Bump version to 1.11.17
Diffstat (limited to 'src/lib/compression')
-rw-r--r--src/lib/compression/compression.cpp3
-rw-r--r--src/lib/compression/zlib/zlib.cpp8
2 files changed, 7 insertions, 4 deletions
diff --git a/src/lib/compression/compression.cpp b/src/lib/compression/compression.cpp
index 89d3a68e7..499fc1adf 100644
--- a/src/lib/compression/compression.cpp
+++ b/src/lib/compression/compression.cpp
@@ -128,16 +128,19 @@ void Stream_Compression::process(secure_vector<byte>& buf, size_t offset, u32bit
void Stream_Compression::update(secure_vector<byte>& buf, size_t offset)
{
+ BOTAN_ASSERT(m_stream, "Initialized");
process(buf, offset, m_stream->run_flag());
}
void Stream_Compression::flush(secure_vector<byte>& buf, size_t offset)
{
+ BOTAN_ASSERT(m_stream, "Initialized");
process(buf, offset, m_stream->flush_flag());
}
void Stream_Compression::finish(secure_vector<byte>& buf, size_t offset)
{
+ BOTAN_ASSERT(m_stream, "Initialized");
process(buf, offset, m_stream->finish_flag());
clear();
}
diff --git a/src/lib/compression/zlib/zlib.cpp b/src/lib/compression/zlib/zlib.cpp
index 415bbccac..a6a724754 100644
--- a/src/lib/compression/zlib/zlib.cpp
+++ b/src/lib/compression/zlib/zlib.cpp
@@ -67,8 +67,8 @@ class Zlib_Compression_Stream : public Zlib_Stream
if(rc == Z_MEM_ERROR)
throw std::bad_alloc();
- else if(rc != Z_OK && rc != Z_STREAM_END)
- throw std::runtime_error("zlib deflate error");
+ else if(rc != Z_OK && rc != Z_STREAM_END && rc != Z_BUF_ERROR)
+ throw std::runtime_error("zlib deflate error " + std::to_string(rc));
return (rc == Z_STREAM_END);
}
@@ -98,8 +98,8 @@ class Zlib_Decompression_Stream : public Zlib_Stream
if(rc == Z_MEM_ERROR)
throw std::bad_alloc();
- else if(rc != Z_OK && rc != Z_STREAM_END)
- throw std::runtime_error("zlib deflate error");
+ else if(rc != Z_OK && rc != Z_STREAM_END && rc != Z_BUF_ERROR)
+ throw std::runtime_error("zlib inflate error " + std::to_string(rc));
return (rc == Z_STREAM_END);
}