diff options
author | Lasse Collin <lasse.collin@tukaani.org> | 2022-02-22 02:04:18 +0200 |
---|---|---|
committer | Lasse Collin <lasse.collin@tukaani.org> | 2022-07-12 19:30:40 +0300 |
commit | b8f667fe0c3e17fd2c559901d2aaf19b1dfd51f2 (patch) | |
tree | d33d6a3132e9b34b6779177120b1832c81fb2b5f /src/liblzma | |
parent | Update THANKS. (diff) | |
download | xz-b8f667fe0c3e17fd2c559901d2aaf19b1dfd51f2.tar.xz |
liblzma: Check the return value of lzma_index_append() in threaded encoder.
If lzma_index_append() failed (most likely memory allocation failure)
it could have gone unnoticed and the resulting .xz file would have
an incorrect Index. Decompressing such a file would produce the
correct uncompressed data but then an error would occur when
verifying the Index field.
Diffstat (limited to '')
-rw-r--r-- | src/liblzma/common/stream_encoder_mt.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/liblzma/common/stream_encoder_mt.c b/src/liblzma/common/stream_encoder_mt.c index 01e40339..2ab4d048 100644 --- a/src/liblzma/common/stream_encoder_mt.c +++ b/src/liblzma/common/stream_encoder_mt.c @@ -715,6 +715,10 @@ stream_encode_mt(void *coder_ptr, const lzma_allocator *allocator, ret = lzma_index_append(coder->index, allocator, unpadded_size, uncompressed_size); + if (ret != LZMA_OK) { + threads_stop(coder, false); + return ret; + } // If we didn't fill the output buffer yet, // try to read more data. Maybe the next @@ -724,8 +728,7 @@ stream_encode_mt(void *coder_ptr, const lzma_allocator *allocator, } if (ret != LZMA_OK) { - // coder->thread_error was set or - // lzma_index_append() failed. + // coder->thread_error was set. threads_stop(coder, false); return ret; } |