aboutsummaryrefslogtreecommitdiff
path: root/src/liblzma
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2022-11-28 10:28:20 +0200
committerLasse Collin <lasse.collin@tukaani.org>2022-11-28 10:28:20 +0200
commite310e8b6a490dfb468f4ed68feff246d776b323c (patch)
treeb3cb94b733020267d5f51beaac6e1ae97890ab46 /src/liblzma
parentliblzma: Add LZMA_FILTER_LZMA1EXT to support LZMA1 without end marker. (diff)
downloadxz-e310e8b6a490dfb468f4ed68feff246d776b323c.tar.xz
liblzma: Use LZMA1EXT feature in lzma_alone_decoder().
This avoids the need to use the slightly ugly method to set the uncompressed size.
Diffstat (limited to '')
-rw-r--r--src/liblzma/common/alone_decoder.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/liblzma/common/alone_decoder.c b/src/liblzma/common/alone_decoder.c
index 5c4d60b1..1dc85bad 100644
--- a/src/liblzma/common/alone_decoder.c
+++ b/src/liblzma/common/alone_decoder.c
@@ -110,12 +110,24 @@ alone_decode(void *coder_ptr, const lzma_allocator *allocator,
// Another hack to ditch false positives: Assume that
// if the uncompressed size is known, it must be less
// than 256 GiB.
+ //
+ // FIXME? Without picky we allow > LZMA_VLI_MAX which doesn't
+ // really matter in this specific situation (> LZMA_VLI_MAX is
+ // safe in the LZMA decoder) but it's somewhat weird still.
if (coder->picky
&& coder->uncompressed_size != LZMA_VLI_UNKNOWN
&& coder->uncompressed_size
>= (LZMA_VLI_C(1) << 38))
return LZMA_FORMAT_ERROR;
+ // Use LZMA_FILTER_LZMA1EXT features to specify the
+ // uncompressed size and that the end marker is allowed
+ // even when the uncompressed size is known. Both .lzma
+ // header and LZMA1EXT use UINT64_MAX indicate that size
+ // is unknown.
+ coder->options.ext_flags = LZMA_LZMA1EXT_ALLOW_EOPM;
+ lzma_set_ext_size(coder->options, coder->uncompressed_size);
+
// Calculate the memory usage so that it is ready
// for SEQ_CODER_INIT.
coder->memusage = lzma_lzma_decoder_memusage(&coder->options)
@@ -132,7 +144,7 @@ alone_decode(void *coder_ptr, const lzma_allocator *allocator,
lzma_filter_info filters[2] = {
{
- .id = LZMA_FILTER_LZMA1,
+ .id = LZMA_FILTER_LZMA1EXT,
.init = &lzma_lzma_decoder_init,
.options = &coder->options,
}, {
@@ -143,10 +155,6 @@ alone_decode(void *coder_ptr, const lzma_allocator *allocator,
return_if_error(lzma_next_filter_init(&coder->next,
allocator, filters));
- // Use a hack to set the uncompressed size.
- lzma_lz_decoder_uncompressed(coder->next.coder,
- coder->uncompressed_size, true);
-
coder->sequence = SEQ_CODE;
break;
}