From 765f0b05f6e95ed9194fb90819cee189ebbac36b Mon Sep 17 00:00:00 2001 From: Lasse Collin Date: Wed, 23 Jan 2008 23:38:18 +0200 Subject: [PATCH] Fix a bug related to 99e12af4e2b866c011fe0106cd1e0bfdcc8fe9c6. lzma_metadata.header_metadata_size was not properly set to zero if the Metadata had only the Metadata Flags field. --- src/liblzma/common/metadata_decoder.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/liblzma/common/metadata_decoder.c b/src/liblzma/common/metadata_decoder.c index 97045750..8ff4e25f 100644 --- a/src/liblzma/common/metadata_decoder.c +++ b/src/liblzma/common/metadata_decoder.c @@ -169,12 +169,6 @@ process(lzma_coder *coder, lzma_allocator *allocator) return LZMA_DATA_ERROR; --coder->todo_count; - } else { - // Zero indicates that Size of Header Metadata Block - // is not present. That is, after successful Metadata - // decoding, metadata->header_metadata_size is - // never LZMA_VLI_VALUE_UNKNOWN. - coder->metadata->header_metadata_size = 0; } coder->sequence = SEQ_TOTAL_SIZE; @@ -494,6 +488,13 @@ metadata_decode(lzma_coder *coder, lzma_allocator *allocator, if (coder->todo_count != 0) return LZMA_DATA_ERROR; + // If Size of Header Metadata Block was not + // present, we use zero as its size instead + // of LZMA_VLI_VALUE_UNKNOWN. + if (coder->metadata->header_metadata_size + == LZMA_VLI_VALUE_UNKNOWN) + coder->metadata->header_metadata_size = 0; + return LZMA_STREAM_END; } }