aboutsummaryrefslogtreecommitdiff
path: root/src/liblzma/lz/lz_decoder.c
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2008-12-15 10:01:59 +0200
committerLasse Collin <lasse.collin@tukaani.org>2008-12-15 10:01:59 +0200
commitff7fb2c605bccc411069e07b9f11fb957aea2ddf (patch)
treec9055532dd69fb9a77147849bb28e55d3e63de6e /src/liblzma/lz/lz_decoder.c
parentName the package "xz" in configure.ac. (diff)
downloadxz-ff7fb2c605bccc411069e07b9f11fb957aea2ddf.tar.xz
Fix data corruption in LZMA2 decoder.
Diffstat (limited to '')
-rw-r--r--src/liblzma/lz/lz_decoder.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/liblzma/lz/lz_decoder.c b/src/liblzma/lz/lz_decoder.c
index d4bd59f2..ce3d50d1 100644
--- a/src/liblzma/lz/lz_decoder.c
+++ b/src/liblzma/lz/lz_decoder.c
@@ -58,6 +58,17 @@ struct lzma_coder_s {
};
+static void
+lz_decoder_reset(lzma_coder *coder)
+{
+ coder->dict.pos = 0;
+ coder->dict.full = 0;
+ coder->dict.buf[coder->dict.size - 1] = '\0';
+ coder->dict.need_reset = false;
+ return;
+}
+
+
static lzma_ret
decode_buffer(lzma_coder *coder,
const uint8_t *restrict in, size_t *restrict in_pos,
@@ -93,6 +104,10 @@ decode_buffer(lzma_coder *coder,
copy_size);
*out_pos += copy_size;
+ // Reset the dictionary if so requested by process().
+ if (coder->dict.need_reset)
+ lz_decoder_reset(coder);
+
// Return if everything got decoded or an error occurred, or
// if there's no more data to decode.
if (ret != LZMA_OK || *out_pos == out_size
@@ -235,7 +250,7 @@ lzma_lz_decoder_init(lzma_next_coder *next, lzma_allocator *allocator,
next->coder->dict.size = dict_size;
}
- dict_reset(&next->coder->dict);
+ lz_decoder_reset(next->coder);
// Miscellaneous initializations
next->coder->next_finished = false;