1
0
mirror of https://git.tukaani.org/xz.git synced 2026-10-31 03:14:56 +00:00

liblzma: lzma_stream_buffer_decode: Fix wrong error code

lzma_stream_buffer_decode() would often fail with LZMA_BUF_ERROR
when it should have failed with LZMA_DATA_ERROR.
In debug builds this also resulted in an assertion failure.

In the _buffer_decode() functions, LZMA_BUF_ERROR is only used when
the output buffer is too small. Truncated input is LZMA_DATA_ERROR.

Reported-by: Guanni Qu
Reported-by: Omkhar Arasaratnam
Fixes: c81f13ff2927 ("Added lzma_stream_buffer_decode() and made minor cleanups.")
This commit is contained in:
Lasse Collin 2026-05-19 13:52:41 +03:00
parent 327c906dcd
commit b53838ae0c
No known key found for this signature in database
GPG Key ID: 38EE757D69184620

View File

@ -50,10 +50,6 @@ lzma_stream_buffer_decode(uint64_t *memlimit, uint32_t flags,
if (ret == LZMA_STREAM_END) {
ret = LZMA_OK;
} else {
// Something went wrong, restore the positions.
*in_pos = in_start;
*out_pos = out_start;
if (ret == LZMA_OK) {
// Either the input was truncated or the
// output buffer was too small.
@ -78,6 +74,10 @@ lzma_stream_buffer_decode(uint64_t *memlimit, uint32_t flags,
stream_decoder.coder,
memlimit, &memusage, 0);
}
// Something went wrong, restore the positions.
*in_pos = in_start;
*out_pos = out_start;
}
}