aboutsummaryrefslogtreecommitdiff
path: root/src/liblzma/common
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2022-11-28 10:48:53 +0200
committerLasse Collin <lasse.collin@tukaani.org>2022-11-28 10:48:53 +0200
commitcee83206465b95729ab649aa2f57fdbde8dcaf89 (patch)
tree9b8125a86202a59d0a42744ef4e845f13ba9ed92 /src/liblzma/common
parentliblzma: Use LZMA1EXT feature in lzma_alone_decoder(). (diff)
downloadxz-cee83206465b95729ab649aa2f57fdbde8dcaf89.tar.xz
liblzma: Use LZMA1EXT feature in lzma_microlzma_decoder().
Here too this avoids the slightly ugly method to set the uncompressed size. Also moved the setting of dict_size to the struct initializer.
Diffstat (limited to 'src/liblzma/common')
-rw-r--r--src/liblzma/common/microlzma_decoder.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/liblzma/common/microlzma_decoder.c b/src/liblzma/common/microlzma_decoder.c
index ba2f10ad..e473373d 100644
--- a/src/liblzma/common/microlzma_decoder.c
+++ b/src/liblzma/common/microlzma_decoder.c
@@ -80,10 +80,17 @@ microlzma_decode(void *coder_ptr, const lzma_allocator *allocator,
return LZMA_OK;
lzma_options_lzma options = {
+ .dict_size = coder->dict_size,
.preset_dict = NULL,
.preset_dict_size = 0,
+ .ext_flags = 0, // EOPM not allowed when size is known
+ .ext_size_low = UINT32_MAX, // Unknown size by default
+ .ext_size_high = UINT32_MAX,
};
+ if (coder->uncomp_size_is_exact)
+ lzma_set_ext_size(options, coder->uncomp_size);
+
// The properties are stored as bitwise-negation
// of the typical encoding.
if (lzma_lzma_lclppb_decode(&options, ~in[*in_pos]))
@@ -92,10 +99,9 @@ microlzma_decode(void *coder_ptr, const lzma_allocator *allocator,
++*in_pos;
// Initialize the decoder.
- options.dict_size = coder->dict_size;
lzma_filter_info filters[2] = {
{
- .id = LZMA_FILTER_LZMA1,
+ .id = LZMA_FILTER_LZMA1EXT,
.init = &lzma_lzma_decoder_init,
.options = &options,
}, {
@@ -106,11 +112,6 @@ microlzma_decode(void *coder_ptr, const lzma_allocator *allocator,
return_if_error(lzma_next_filter_init(&coder->lzma,
allocator, filters));
- // Use a hack to set the uncompressed size.
- if (coder->uncomp_size_is_exact)
- lzma_lz_decoder_uncompressed(coder->lzma.coder,
- coder->uncomp_size, false);
-
// Pass one dummy 0x00 byte to the LZMA decoder since that
// is what it expects the first byte to be.
const uint8_t dummy_in = 0;