From c4e8e5fb311225b8b48d34157891a640b2535e0c Mon Sep 17 00:00:00 2001 From: Lasse Collin Date: Thu, 18 Aug 2022 17:16:49 +0300 Subject: liblzma: Threaded decoder: Improve LZMA_FAIL_FAST when LZMA_FINISH is used. It will now return LZMA_DATA_ERROR (not LZMA_OK or LZMA_BUF_ERROR) if LZMA_FINISH is used and there isn't enough input to finish decoding the Block Header or the Block. The use of LZMA_DATA_ERROR is simpler and the less risky than LZMA_BUF_ERROR but this might be changed before 5.4.0. --- src/liblzma/api/lzma/container.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/liblzma/api/lzma') diff --git a/src/liblzma/api/lzma/container.h b/src/liblzma/api/lzma/container.h index 564c6aaf..c0e1f5b4 100644 --- a/src/liblzma/api/lzma/container.h +++ b/src/liblzma/api/lzma/container.h @@ -623,6 +623,12 @@ extern LZMA_API(lzma_ret) lzma_microlzma_encoder( * decompressed multiple times with this flag, a different amount of output * may be produced by different runs, and even the error code might vary. * + * When using LZMA_FAIL_FAST, it is recommended to use LZMA_FINISH to tell + * the decoder when no more input will be coming because it can help fast + * detection and reporting of truncated files. Note that in this situation + * truncated files might be diagnosed with LZMA_DATA_ERROR instead of + * LZMA_OK or LZMA_BUF_ERROR! + * * Without this flag the threaded decoder will provide as much output as * possible at first and then report the pending error. This default behavior * matches the single-threaded decoder and provides repeatable behavior -- cgit v1.2.3