libbacktrace: skip all LZMA block header padding bytes (28824f2)

This commit is contained in:
Bartosz Taudul 2024-03-13 00:24:13 +01:00
parent 1f90cd473b
commit 49478ec3b3
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3

View File

@ -5586,6 +5586,7 @@ elf_uncompress_lzma_block (const unsigned char *compressed,
uint64_t header_compressed_size; uint64_t header_compressed_size;
uint64_t header_uncompressed_size; uint64_t header_uncompressed_size;
unsigned char lzma2_properties; unsigned char lzma2_properties;
size_t crc_offset;
uint32_t computed_crc; uint32_t computed_crc;
uint32_t stream_crc; uint32_t stream_crc;
size_t uncompressed_offset; size_t uncompressed_offset;
@ -5689,19 +5690,20 @@ elf_uncompress_lzma_block (const unsigned char *compressed,
/* The properties describe the dictionary size, but we don't care /* The properties describe the dictionary size, but we don't care
what that is. */ what that is. */
/* Block header padding. */ /* Skip to just before CRC, verifying zero bytes in between. */
if (unlikely (off + 4 > compressed_size)) crc_offset = block_header_offset + block_header_size - 4;
if (unlikely (crc_offset + 4 > compressed_size))
{ {
elf_uncompress_failed (); elf_uncompress_failed ();
return 0; return 0;
} }
for (; off < crc_offset; off++)
off = (off + 3) &~ (size_t) 3;
if (unlikely (off + 4 > compressed_size))
{ {
elf_uncompress_failed (); if (compressed[off] != 0)
return 0; {
elf_uncompress_failed ();
return 0;
}
} }
/* Block header CRC. */ /* Block header CRC. */