aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/lib/compression/compress_utils.cpp6
-rw-r--r--src/tests/test_compression.cpp16
2 files changed, 20 insertions, 2 deletions
diff --git a/src/lib/compression/compress_utils.cpp b/src/lib/compression/compress_utils.cpp
index ceb180c4b..6edc22292 100644
--- a/src/lib/compression/compress_utils.cpp
+++ b/src/lib/compression/compress_utils.cpp
@@ -68,6 +68,12 @@ void Stream_Compression::process(secure_vector<uint8_t>& buf, size_t offset, uin
BOTAN_ASSERT(m_stream, "Initialized");
BOTAN_ASSERT(buf.size() >= offset, "Offset is sane");
+ // bzip doesn't like being called with no input and BZ_RUN
+ if(buf.size() == offset && flags == m_stream->run_flag())
+ {
+ return;
+ }
+
if(m_buffer.size() < buf.size() + offset)
m_buffer.resize(buf.size() + offset);
diff --git a/src/tests/test_compression.cpp b/src/tests/test_compression.cpp
index 10e93eb79..4cb9ece8b 100644
--- a/src/tests/test_compression.cpp
+++ b/src/tests/test_compression.cpp
@@ -125,15 +125,27 @@ class Compression_Tests final : public Test
const Botan::secure_vector<uint8_t>& msg)
{
Botan::secure_vector<uint8_t> compressed = msg;
+ Botan::secure_vector<uint8_t> flush_bits;
+ Botan::secure_vector<uint8_t> final_bits;
c.start(level);
- c.finish(compressed);
+ c.update(compressed);
+ c.update(flush_bits, 0, true);
+ c.finish(final_bits);
+
+ compressed += flush_bits;
+ compressed += final_bits;
const size_t c_size = compressed.size();
Botan::secure_vector<uint8_t> decompressed = compressed;
d.start();
- d.finish(decompressed);
+ d.update(decompressed);
+
+ Botan::secure_vector<uint8_t> final_outputs;
+ d.finish(final_outputs);
+
+ decompressed += final_outputs;
result.test_eq("compression round tripped", msg, decompressed);
return c_size;