diff options
author | Lasse Collin <lasse.collin@tukaani.org> | 2021-01-17 19:20:50 +0200 |
---|---|---|
committer | Lasse Collin <lasse.collin@tukaani.org> | 2021-01-17 19:20:50 +0200 |
commit | db465419ae26ec7fb9b9472183911ff521620c77 (patch) | |
tree | 097c2af1103adf4b8aa7e9937bd2c54e39f4a4d0 | |
parent | liblzma: Make EROFS LZMA decoder work when exact uncomp_size isn't known. (diff) | |
download | xz-db465419ae26ec7fb9b9472183911ff521620c77.tar.xz |
liblzma: In EROFS LZMA decoder, verify that comp_size matches at the end.
When the uncompressed size is known to be exact, after decompressing
the stream exactly comp_size bytes of input must have been consumed.
This is a minor improvement to error detection.
-rw-r--r-- | src/liblzma/common/erofs_decoder.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/liblzma/common/erofs_decoder.c b/src/liblzma/common/erofs_decoder.c index 816e2482..9264adda 100644 --- a/src/liblzma/common/erofs_decoder.c +++ b/src/liblzma/common/erofs_decoder.c @@ -132,7 +132,12 @@ erofs_decode(void *coder_ptr, const lzma_allocator *allocator, assert(coder->comp_size >= *in_pos - in_start); coder->comp_size -= *in_pos - in_start; - if (!coder->uncomp_size_is_exact) { + if (coder->uncomp_size_is_exact) { + // After successful decompression of the complete stream + // the compressed size must match. + if (ret == LZMA_STREAM_END && coder->comp_size != 0) + ret = LZMA_DATA_ERROR; + } else { // Update the amount of output remaining. assert(coder->uncomp_size >= *out_pos - out_start); coder->uncomp_size -= *out_pos - out_start; |