aboutsummaryrefslogtreecommitdiff
path: root/src/liblzma/common
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2008-12-01 22:59:28 +0200
committerLasse Collin <lasse.collin@tukaani.org>2008-12-01 22:59:28 +0200
commitccd57afa09e332d664d6d6a7498702791ea5f659 (patch)
treeeb1af999c9755a6cd3fc32678db112a54b9a1262 /src/liblzma/common
parentMake the memusage functions of LZMA1 and LZMA2 decoders (diff)
downloadxz-ccd57afa09e332d664d6d6a7498702791ea5f659.tar.xz
Validate the filter chain before checking filter-specific
memory usage.
Diffstat (limited to 'src/liblzma/common')
-rw-r--r--src/liblzma/common/filter_common.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/liblzma/common/filter_common.c b/src/liblzma/common/filter_common.c
index 03b6859a..13a7cdd2 100644
--- a/src/liblzma/common/filter_common.c
+++ b/src/liblzma/common/filter_common.c
@@ -227,8 +227,11 @@ lzma_memusage_coder(lzma_filter_find coder_find,
const lzma_filter *filters)
{
// The chain has to have at least one filter.
- if (filters[0].id == LZMA_VLI_UNKNOWN)
- return UINT64_MAX;
+ {
+ size_t tmp;
+ if (validate_chain(filters, &tmp) != LZMA_OK)
+ return UINT64_MAX;
+ }
uint64_t total = 0;
size_t i = 0;
@@ -241,8 +244,11 @@ lzma_memusage_coder(lzma_filter_find coder_find,
if (fc->memusage == NULL) {
// This filter doesn't have a function to calculate
- // the memory usage. Such filters need only little
- // memory, so we use 1 KiB as a good estimate.
+ // the memory usage and validate the options. Such
+ // filters need only little memory, so we use 1 KiB
+ // as a good estimate. They also accept all possible
+ // options, so there's no need to worry about lack
+ // of validation.
total += 1024;
} else {
// Call the filter-specific memory usage calculation