aboutsummaryrefslogtreecommitdiff
path: root/src/liblzma/common/stream_buffer_encoder.c
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2011-04-11 13:21:28 +0300
committerLasse Collin <lasse.collin@tukaani.org>2011-04-11 13:21:28 +0300
commit71b9380145dccf001f22e66a06b9d508905c25ce (patch)
tree76d7f8a717ec93d0f59371656f01c83a1f179979 /src/liblzma/common/stream_buffer_encoder.c
parentxz: Move the description of --block-size in --long-help. (diff)
downloadxz-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/stream_buffer_encoder.c3
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