diff options
author | Jack Lloyd <[email protected]> | 2017-11-25 12:50:17 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2017-11-25 12:50:17 -0500 |
commit | 121f8bee6c2c6891bfb855d39aad66703e0ae35e (patch) | |
tree | f8dc1f6cfff1e0b3a66c0048bbac9e2943410a4a /src/lib/compression | |
parent | 3f8c4add59f4db347f8594a49c846c85ce1e296d (diff) |
Fix bzip2 compression issue.
When finishing, bzip2 returns BZ_STREAM_END when it has produced all output.
If we end up calling the compression routine again (even with avail_in == 0),
bzip2 returns an error.
Diffstat (limited to 'src/lib/compression')
-rw-r--r-- | src/lib/compression/compress_utils.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/lib/compression/compress_utils.cpp b/src/lib/compression/compress_utils.cpp index f4b41fd5b..6bdf3d0fd 100644 --- a/src/lib/compression/compress_utils.cpp +++ b/src/lib/compression/compress_utils.cpp @@ -84,9 +84,15 @@ void Stream_Compression::process(secure_vector<uint8_t>& buf, size_t offset, uin while(true) { - m_stream->run(flags); + const bool stream_end = m_stream->run(flags); - if(m_stream->avail_out() == 0) + if(stream_end) + { + BOTAN_ASSERT(m_stream->avail_in() == 0, "After stream is done, no input remains to be processed"); + m_buffer.resize(m_buffer.size() - m_stream->avail_out()); + break; + } + else if(m_stream->avail_out() == 0) { const size_t added = 8 + m_buffer.size(); m_buffer.resize(m_buffer.size() + added); |