diff options
author | Lasse Collin <lasse.collin@tukaani.org> | 2011-04-11 13:21:28 +0300 |
---|---|---|
committer | Lasse Collin <lasse.collin@tukaani.org> | 2011-04-11 13:21:28 +0300 |
commit | 71b9380145dccf001f22e66a06b9d508905c25ce (patch) | |
tree | 76d7f8a717ec93d0f59371656f01c83a1f179979 /src/liblzma/common/block_encoder.c | |
parent | xz: Move the description of --block-size in --long-help. (diff) | |
download | xz-71b9380145dccf001f22e66a06b9d508905c25ce.tar.xz |
liblzma: Validate encoder arguments better.
The biggest problem was that the integrity check type
wasn't validated, and e.g. lzma_easy_buffer_encode()
would create a corrupt .xz Stream if given an unsupported
Check ID. Luckily applications don't usually try to use
an unsupport Check ID, so this bug is unlikely to cause
many real-world problems.
Diffstat (limited to '')
-rw-r--r-- | src/liblzma/common/block_encoder.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/liblzma/common/block_encoder.c b/src/liblzma/common/block_encoder.c index ca515235..b34c5013 100644 --- a/src/liblzma/common/block_encoder.c +++ b/src/liblzma/common/block_encoder.c @@ -161,6 +161,11 @@ lzma_block_encoder_init(lzma_next_coder *next, lzma_allocator *allocator, { lzma_next_coder_init(&lzma_block_encoder_init, next, allocator); + if (block == NULL) + return LZMA_PROG_ERROR; + + // The contents of the structure may depend on the version so + // check the version first. if (block->version != 0) return LZMA_OPTIONS_ERROR; |