diff options
author | Jia Tan <jiat0218@gmail.com> | 2022-09-02 20:18:55 +0800 |
---|---|---|
committer | Lasse Collin <lasse.collin@tukaani.org> | 2022-09-17 00:21:54 +0300 |
commit | 72e1645a439a999638a63ec9abb7210671ea5415 (patch) | |
tree | fe58e1ec058f1b5597d625b9ff1797612ef3157c /src | |
parent | Update THANKS. (diff) | |
download | xz-72e1645a439a999638a63ec9abb7210671ea5415.tar.xz |
liblzma: lzma_index_append: Add missing integer overflow check.
The documentation in src/liblzma/api/lzma/index.h suggests that
both the unpadded (compressed) size and the uncompressed size
are checked for overflow, but only the unpadded size was checked.
The uncompressed check is done first since that is more likely to
occur than the unpadded or index field size overflows.
Diffstat (limited to 'src')
-rw-r--r-- | src/liblzma/common/index.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/liblzma/common/index.c b/src/liblzma/common/index.c index 86c10544..010e1f80 100644 --- a/src/liblzma/common/index.c +++ b/src/liblzma/common/index.c @@ -656,6 +656,10 @@ lzma_index_append(lzma_index *i, const lzma_allocator *allocator, const uint32_t index_list_size_add = lzma_vli_size(unpadded_size) + lzma_vli_size(uncompressed_size); + // Check that uncompressed size will not overflow. + if (uncompressed_base + uncompressed_size > LZMA_VLI_MAX) + return LZMA_DATA_ERROR; + // Check that the file size will stay within limits. if (index_file_size(s->node.compressed_base, compressed_base + unpadded_size, s->record_count + 1, |