From cb072b7c8442ba68bb0c62c0abbbe939794887a3 Mon Sep 17 00:00:00 2001 From: Lasse Collin Date: Wed, 10 Sep 2008 17:02:00 +0300 Subject: Check for LZMA_FILTER_RESERVED_START in filter_flags_encoder.c. Use LZMA_PROG_ERROR instead of LZMA_HEADER_ERROR if the Filter ID is in the reserved range. This allows Block Header encoder to detect unallowed Filter IDs, which is good for Stream encoder. --- src/liblzma/common/filter_flags_encoder.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/liblzma') diff --git a/src/liblzma/common/filter_flags_encoder.c b/src/liblzma/common/filter_flags_encoder.c index 46464c0f..22b6dd1f 100644 --- a/src/liblzma/common/filter_flags_encoder.c +++ b/src/liblzma/common/filter_flags_encoder.c @@ -23,10 +23,11 @@ extern LZMA_API lzma_ret lzma_filter_flags_size(uint32_t *size, const lzma_filter *filter) { + if (filter->id >= LZMA_FILTER_RESERVED_START) + return LZMA_PROG_ERROR; + return_if_error(lzma_properties_size(size, filter)); - // lzma_properties_size() validates the Filter ID as a side-effect, - // so we know that it is a valid VLI. *size += lzma_vli_size(filter->id) + lzma_vli_size(*size); return LZMA_OK; @@ -39,7 +40,7 @@ lzma_filter_flags_encode(const lzma_filter *filter, { // Filter ID if (filter->id >= LZMA_FILTER_RESERVED_START) - return LZMA_HEADER_ERROR; + return LZMA_PROG_ERROR; return_if_error(lzma_vli_encode(filter->id, NULL, out, out_pos, out_size)); -- cgit v1.2.3