diff options
author | Lasse Collin <lasse.collin@tukaani.org> | 2008-12-15 10:01:59 +0200 |
---|---|---|
committer | Lasse Collin <lasse.collin@tukaani.org> | 2008-12-15 10:01:59 +0200 |
commit | ff7fb2c605bccc411069e07b9f11fb957aea2ddf (patch) | |
tree | c9055532dd69fb9a77147849bb28e55d3e63de6e /src/liblzma/lzma | |
parent | Name the package "xz" in configure.ac. (diff) | |
download | xz-ff7fb2c605bccc411069e07b9f11fb957aea2ddf.tar.xz |
Fix data corruption in LZMA2 decoder.
Diffstat (limited to 'src/liblzma/lzma')
-rw-r--r-- | src/liblzma/lzma/lzma2_decoder.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/liblzma/lzma/lzma2_decoder.c b/src/liblzma/lzma/lzma2_decoder.c index 4470b4b1..ff90803b 100644 --- a/src/liblzma/lzma/lzma2_decoder.c +++ b/src/liblzma/lzma/lzma2_decoder.c @@ -74,12 +74,11 @@ lzma2_decode(lzma_coder *restrict coder, lzma_dict *restrict dict, const uint32_t control = in[*in_pos]; ++*in_pos; - // Dictionary reset implies that next LZMA chunk has to set - // new properties. if (control >= 0xE0 || control == 1) { - dict_reset(dict); - coder->need_dictionary_reset = false; + // Dictionary reset implies that next LZMA chunk has + // to set new properties. coder->need_properties = true; + coder->need_dictionary_reset = true; } else if (coder->need_dictionary_reset) { return LZMA_DATA_ERROR; } @@ -125,6 +124,14 @@ lzma2_decode(lzma_coder *restrict coder, lzma_dict *restrict dict, coder->next_sequence = SEQ_COPY; } + if (coder->need_dictionary_reset) { + // Finish the dictionary reset and let the caller + // flush the dictionary to the actual output buffer. + coder->need_dictionary_reset = false; + dict_reset(dict); + return LZMA_OK; + } + break; } |