LZX, XPRESS decompression: Return 0 bits on overrun
authorEric Biggers <ebiggers3@gmail.com>
Tue, 27 May 2014 16:03:07 +0000 (11:03 -0500)
committerEric Biggers <ebiggers3@gmail.com>
Tue, 27 May 2014 16:19:15 +0000 (11:19 -0500)
commit63be24f6367f907c49d3bc1d6ac86311bd0cba68
tree4732080f6eba5d54307d2e9e4a2757973ebf17f2
parent869ca1f4cc4654501d52f8c3e660c056904ccabf
LZX, XPRESS decompression:  Return 0 bits on overrun

If the compressed data is invalid such that the compressed data buffer is
overrun, it's simpler to just return 0 bits instead of explicitly
checking the return value at every call site of bitstream_read_bits() and
read_huffsym().

This doesn't necessarily mean that invalid data will go undetected.  Just
for LZX decompression, chances are there will be another problem if all
0's start being returned (e.g. invalid match or invalid Huffman tree).
For WIM operations like extraction, the uncompressed data is checked with
SHA-1 message digests anyway, so it's virtually impossible for corruption
to go undetected.

Also, the LZMS decompressor already does this.
include/wimlib/decompress_common.h
src/decompress_common.c
src/lzx-decompress.c
src/xpress-decompress.c