mirror of
https://git.tukaani.org/xz.git
synced 2024-04-04 12:36:23 +02:00
xz: Validate Uncompressed Size from Block Header in list.c.
This affects only "xz -lvv". Normal decompression with xz already detected if Block Header and Index had mismatched Uncompressed Size fields. So this just makes "xz -lvv" show such files as corrupt instead of showing the Uncompressed Size from Index.
This commit is contained in:
parent
c09e91dd23
commit
ebb501ec73
1 changed files with 13 additions and 1 deletions
|
@ -456,8 +456,20 @@ parse_block_header(file_pair *pair, const lzma_index_iter *iter,
|
||||||
switch (lzma_block_compressed_size(&block,
|
switch (lzma_block_compressed_size(&block,
|
||||||
iter->block.unpadded_size)) {
|
iter->block.unpadded_size)) {
|
||||||
case LZMA_OK:
|
case LZMA_OK:
|
||||||
|
// Validate also block.uncompressed_size if it is present.
|
||||||
|
// If it isn't present, there's no need to set it since
|
||||||
|
// we aren't going to actually decompress the Block; if
|
||||||
|
// we were decompressing, then we should set it so that
|
||||||
|
// the Block decoder could validate the Uncompressed Size
|
||||||
|
// that was stored in the Index.
|
||||||
|
if (block.uncompressed_size == LZMA_VLI_UNKNOWN
|
||||||
|
|| block.uncompressed_size
|
||||||
|
== iter->block.uncompressed_size)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
// If the above fails, the file is corrupt so
|
||||||
|
// LZMA_DATA_ERROR is a good error code.
|
||||||
|
|
||||||
case LZMA_DATA_ERROR:
|
case LZMA_DATA_ERROR:
|
||||||
// Free the memory allocated by lzma_block_header_decode().
|
// Free the memory allocated by lzma_block_header_decode().
|
||||||
for (size_t i = 0; filters[i].id != LZMA_VLI_UNKNOWN; ++i)
|
for (size_t i = 0; filters[i].id != LZMA_VLI_UNKNOWN; ++i)
|
||||||
|
|
Loading…
Reference in a new issue