diff options
author | Lasse Collin <lasse.collin@tukaani.org> | 2022-10-25 23:09:11 +0300 |
---|---|---|
committer | Lasse Collin <lasse.collin@tukaani.org> | 2022-11-11 13:38:34 +0200 |
commit | 01744b280c6e35d331b9dc4cc64716b82bc8b3db (patch) | |
tree | 62d9bdd760d89c691c541d9d2b809ed63cc1cf2c /src | |
parent | xz: Fix decompressor behavior if input uses an unsupported check type. (diff) | |
download | xz-01744b280c6e35d331b9dc4cc64716b82bc8b3db.tar.xz |
xz: Fix --single-stream with an empty .xz Stream.
Example:
$ xz -dc --single-stream good-0-empty.xz
xz: good-0-empty.xz: Internal error (bug)
The code, that is tries to catch some input file issues early,
didn't anticipate LZMA_STREAM_END which is possible in that
code only when --single-stream is used.
Diffstat (limited to '')
-rw-r--r-- | src/xz/coder.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/xz/coder.c b/src/xz/coder.c index bc905594..51cd3ef0 100644 --- a/src/xz/coder.c +++ b/src/xz/coder.c @@ -557,6 +557,15 @@ coder_init(file_pair *pair) == LZMA_UNSUPPORTED_CHECK) message_warning("%s: %s", pair->src_name, message_strm(ret)); + + // With --single-stream lzma_code won't wait for + // LZMA_FINISH and thus it can return LZMA_STREAM_END + // if the file has no uncompressed data inside. + // So treat LZMA_STREAM_END as LZMA_OK here. + // When lzma_code() is called again in coder_normal() + // it will return LZMA_STREAM_END again. + if (ret == LZMA_STREAM_END) + ret = LZMA_OK; } #endif } |