From 774cc0118ba2496581cb2621505a04bb6598cc75 Mon Sep 17 00:00:00 2001 From: Lasse Collin Date: Sun, 17 Jan 2021 18:53:34 +0200 Subject: liblzma: Make EROFS LZMA decoder work when exact uncomp_size isn't known. The caller must still not specify an uncompressed size bigger than the actual uncompressed size. As a downside, this now needs the exact compressed size. --- src/liblzma/api/lzma/container.h | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'src/liblzma/api') diff --git a/src/liblzma/api/lzma/container.h b/src/liblzma/api/lzma/container.h index 581f3507..4ad7ce6a 100644 --- a/src/liblzma/api/lzma/container.h +++ b/src/liblzma/api/lzma/container.h @@ -690,11 +690,22 @@ extern LZMA_API(lzma_ret) lzma_stream_buffer_decode( * The special behavior of lzma_code() applies to lzma_erofs_encoder() only. * * \param strm Pointer to properly prepared lzma_stream + * \param comp_size Compressed size of the EROFS LZMA stream. + * The caller must somehow know this exactly. * \param uncomp_size Uncompressed size of the EROFS LZMA stream. - * The caller must somehow know this. Note that - * while the EROFS LZMA decoder in XZ Embedded needs - * also the compressed size, the implementation in - * liblzma doesn't need to know the compressed size. + * If the exact uncompressed size isn't known, this + * can be set to a value that is at most as big as + * the exact uncompressed size would be, but then the + * next argument uncomp_size_is_exact must be false. + * \param uncomp_size_is_exact + * If true, uncomp_size must be exactly correct. + * This will improve error detection at the end of + * the stream. If the exact uncompressed size isn't + * known, this must be false. uncomp_size must still + * be at most as big as the exact uncompressed size + * is. Setting this to false when the exact size is + * known will work but error detection at the end of + * the stream will be weaker. * \param dict_size LZMA dictionary size that was used when * compressing the data. It is OK to use a bigger * value too but liblzma will then allocate more @@ -705,4 +716,6 @@ extern LZMA_API(lzma_ret) lzma_stream_buffer_decode( * dictionary than actually required.) */ extern LZMA_API(lzma_ret) lzma_erofs_decoder( - lzma_stream *strm, uint64_t uncomp_size, uint32_t dict_size); + lzma_stream *strm, uint64_t comp_size, + uint64_t uncomp_size, lzma_bool uncomp_size_is_exact, + uint32_t dict_size); -- cgit v1.2.3