diff options
author | Lasse Collin <lasse.collin@tukaani.org> | 2022-12-08 17:30:09 +0200 |
---|---|---|
committer | Lasse Collin <lasse.collin@tukaani.org> | 2022-12-12 15:47:17 +0200 |
commit | 7623b22d1d59c78033425a2448613837bcd203a2 (patch) | |
tree | d87f12c637054bf5353eb281bfb86ccf59617f84 /src/liblzma/common | |
parent | liblzma: Use __has_attribute(__symver__) to fix Clang detection. (diff) | |
download | xz-7623b22d1d59c78033425a2448613837bcd203a2.tar.xz |
liblzma: Check for unexpected NULL pointers in block_header_decode().
The API docs gave an impression that such checks are done
but they actually weren't done. In practice it made little
difference since the calling code has a bug if these are NULL.
Thanks to Jia Tan for the original patch that checked for
block->filters == NULL.
Diffstat (limited to 'src/liblzma/common')
-rw-r--r-- | src/liblzma/common/block_header_decoder.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/liblzma/common/block_header_decoder.c b/src/liblzma/common/block_header_decoder.c index 2e1135dd..060479b4 100644 --- a/src/liblzma/common/block_header_decoder.c +++ b/src/liblzma/common/block_header_decoder.c @@ -39,6 +39,10 @@ lzma_block_header_decode(lzma_block *block, // are invalid or over 63 bits, or if the header is too small // to contain the claimed information. + // Catch unexpected NULL pointers. + if (block == NULL || block->filters == NULL || in == NULL) + return LZMA_PROG_ERROR; + // Initialize the filter options array. This way the caller can // safely free() the options even if an error occurs in this function. for (size_t i = 0; i <= LZMA_FILTERS_MAX; ++i) { |