mirror of
https://git.tukaani.org/xz.git
synced 2026-10-31 19:34:55 +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:
parent
327c906dcd
commit
b53838ae0c
@ -50,10 +50,6 @@ lzma_stream_buffer_decode(uint64_t *memlimit, uint32_t flags,
|
|||||||
if (ret == LZMA_STREAM_END) {
|
if (ret == LZMA_STREAM_END) {
|
||||||
ret = LZMA_OK;
|
ret = LZMA_OK;
|
||||||
} else {
|
} else {
|
||||||
// Something went wrong, restore the positions.
|
|
||||||
*in_pos = in_start;
|
|
||||||
*out_pos = out_start;
|
|
||||||
|
|
||||||
if (ret == LZMA_OK) {
|
if (ret == LZMA_OK) {
|
||||||
// Either the input was truncated or the
|
// Either the input was truncated or the
|
||||||
// output buffer was too small.
|
// output buffer was too small.
|
||||||
@ -78,6 +74,10 @@ lzma_stream_buffer_decode(uint64_t *memlimit, uint32_t flags,
|
|||||||
stream_decoder.coder,
|
stream_decoder.coder,
|
||||||
memlimit, &memusage, 0);
|
memlimit, &memusage, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Something went wrong, restore the positions.
|
||||||
|
*in_pos = in_start;
|
||||||
|
*out_pos = out_start;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user