aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2014-11-25 12:32:05 +0200
committerLasse Collin <lasse.collin@tukaani.org>2014-11-25 12:32:05 +0200
commit2301f3f05dd9742f42cda8f0f318864f5dc39ab3 (patch)
tree2064480f15ad902e3e835138a33dd97f4cfe2a1b /src
parentBuild: Update m4/ax_pthread.m4 from Autoconf Archive. (diff)
downloadxz-2301f3f05dd9742f42cda8f0f318864f5dc39ab3.tar.xz
liblzma: Verify the filter chain in threaded encoder initialization.
This way an invalid filter chain is detected at the Stream encoder initialization instead of delaying it to the first call to lzma_code() which triggers the initialization of the actual filter encoder(s).
Diffstat (limited to 'src')
-rw-r--r--src/liblzma/common/stream_encoder_mt.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/liblzma/common/stream_encoder_mt.c b/src/liblzma/common/stream_encoder_mt.c
index 6188507f..9780ed04 100644
--- a/src/liblzma/common/stream_encoder_mt.c
+++ b/src/liblzma/common/stream_encoder_mt.c
@@ -947,9 +947,12 @@ stream_encoder_mt_init(lzma_next_coder *next, const lzma_allocator *allocator,
return LZMA_MEM_ERROR;
#endif
- // FIXME TODO: Validate the filter chain so that we can give
- // an error in this function instead of delaying it to the first
- // call to lzma_code().
+ // Validate the filter chain so that we can give an error in this
+ // function instead of delaying it to the first call to lzma_code().
+ // The memory usage calculation verifies the filter chain as
+ // a side effect so we take advatange of that.
+ if (lzma_raw_encoder_memusage(filters) == UINT64_MAX)
+ return LZMA_OPTIONS_ERROR;
// Validate the Check ID.
if ((unsigned int)(options->check) > LZMA_CHECK_ID_MAX)