diff options
author | Lasse Collin <lasse.collin@tukaani.org> | 2013-06-23 17:36:47 +0300 |
---|---|---|
committer | Lasse Collin <lasse.collin@tukaani.org> | 2013-06-23 17:36:47 +0300 |
commit | ebb501ec73cecc546c67117dd01b5e33c90bfb4a (patch) | |
tree | 745948089b3b2e6ec51e8094eae7175220041372 /src/xz | |
parent | Update THANKS. (diff) | |
download | xz-ebb501ec73cecc546c67117dd01b5e33c90bfb4a.tar.xz |
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.
Diffstat (limited to 'src/xz')
-rw-r--r-- | src/xz/list.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/xz/list.c b/src/xz/list.c index a9e0adb9..13abd8f7 100644 --- a/src/xz/list.c +++ b/src/xz/list.c @@ -456,7 +456,19 @@ parse_block_header(file_pair *pair, const lzma_index_iter *iter, switch (lzma_block_compressed_size(&block, iter->block.unpadded_size)) { case LZMA_OK: - break; + // 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; + + // If the above fails, the file is corrupt so + // LZMA_DATA_ERROR is a good error code. case LZMA_DATA_ERROR: // Free the memory allocated by lzma_block_header_decode(). |