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 14:00:46 +0300 |
commit | 4ce1cf97a88ae1640a380dd19cbc255d729f966b (patch) | |
tree | 7671afcc5daf64a2c02f5fe967e45cba0f2c95f8 /src/liblzma/common/stream_buffer_encoder.c | |
parent | Update THANKS. (diff) | |
download | xz-4ce1cf97a88ae1640a380dd19cbc255d729f966b.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 'src/liblzma/common/stream_buffer_encoder.c')
-rw-r--r-- | src/liblzma/common/stream_buffer_encoder.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/liblzma/common/stream_buffer_encoder.c b/src/liblzma/common/stream_buffer_encoder.c index f727d854..dd23c9af 100644 --- a/src/liblzma/common/stream_buffer_encoder.c +++ b/src/liblzma/common/stream_buffer_encoder.c @@ -51,6 +51,9 @@ lzma_stream_buffer_encode(lzma_filter *filters, lzma_check check, || out_pos_ptr == NULL || *out_pos_ptr > out_size) return LZMA_PROG_ERROR; + if (!lzma_check_is_supported(check)) + return LZMA_UNSUPPORTED_CHECK; + // Note for the paranoids: Index encoder prevents the Stream from // getting too big and still being accepted with LZMA_OK, and Block // encoder catches if the input is too big. So we don't need to |