aboutsummaryrefslogtreecommitdiff
path: root/src/liblzma/common
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2008-09-10 17:02:00 +0300
committerLasse Collin <lasse.collin@tukaani.org>2008-09-10 17:02:00 +0300
commitcb072b7c8442ba68bb0c62c0abbbe939794887a3 (patch)
treeb8e1852f45fb03fe06e75a3c11a9a15ca7eb6b11 /src/liblzma/common
parentFilter handling cleanups (diff)
downloadxz-cb072b7c8442ba68bb0c62c0abbbe939794887a3.tar.xz
Check for LZMA_FILTER_RESERVED_START in filter_flags_encoder.c.larhzu/v4.999.5alpha
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.
Diffstat (limited to 'src/liblzma/common')
-rw-r--r--src/liblzma/common/filter_flags_encoder.c7
1 files changed, 4 insertions, 3 deletions
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));