lzma_bool eat_index)
{
// Validate *metadata.
- if (!lzma_vli_is_valid(metadata->header_metadata_size)
+ if (metadata->header_metadata_size > LZMA_VLI_VALUE_MAX
|| !lzma_vli_is_valid(metadata->total_size)
|| !lzma_vli_is_valid(metadata->uncompressed_size)) {
if (eat_index) {
}
// Size of Header Metadata
- if (!is_header_metadata) {
- // If it is marked unknown in Metadata, it means that
- // it's not present.
- const lzma_vli size = metadata->header_metadata_size
- != LZMA_VLI_VALUE_UNKNOWN
- ? metadata->header_metadata_size : 0;
+ if (!is_header_metadata)
return_if_error(lzma_info_size_set(
- info, LZMA_INFO_HEADER_METADATA, size));
- }
+ info, LZMA_INFO_HEADER_METADATA,
+ metadata->header_metadata_size));
// Total Size
if (metadata->total_size != LZMA_VLI_VALUE_UNKNOWN)
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;
case SEQ_FLAGS:
coder->buffer[coder->buffer_size] = 0;
- if (coder->metadata.header_metadata_size
- != LZMA_VLI_VALUE_UNKNOWN)
+ if (coder->metadata.header_metadata_size != 0)
coder->buffer[coder->buffer_size] |= 0x01;
if (coder->metadata.total_size != LZMA_VLI_VALUE_UNKNOWN)
break;
case SEQ_HEADER_METADATA_SIZE:
- if (coder->metadata.header_metadata_size
- != LZMA_VLI_VALUE_UNKNOWN)
+ if (coder->metadata.header_metadata_size != 0)
write_vli(coder->metadata.header_metadata_size);
coder->sequence = SEQ_TOTAL_SIZE;
lzma_vli size = 1; // Metadata Flags
// Validate header_metadata_size, total_size, and uncompressed_size.
- if (!lzma_vli_is_valid(metadata->header_metadata_size)
+ if (metadata->header_metadata_size > LZMA_VLI_VALUE_MAX
|| !lzma_vli_is_valid(metadata->total_size)
+ || metadata->total_size == 0
|| !lzma_vli_is_valid(metadata->uncompressed_size))
return 0;
// Add the sizes of these three fields.
- if (metadata->header_metadata_size != LZMA_VLI_VALUE_UNKNOWN)
+ if (metadata->header_metadata_size != 0)
size += lzma_vli_size(metadata->header_metadata_size);
if (metadata->total_size != LZMA_VLI_VALUE_UNKNOWN)
// still present in Footer.
reset();
metadata = my_metadata;
- metadata.header_metadata_size = LZMA_VLI_VALUE_UNKNOWN;
+ metadata.header_metadata_size = 0;
expect(lzma_info_size_set(info, LZMA_INFO_HEADER_METADATA, 0)
== LZMA_OK);
expect(lzma_info_metadata_set(info, NULL, &metadata, true, false)
// from Footer.
reset();
metadata = my_metadata;
- metadata.header_metadata_size = LZMA_VLI_VALUE_UNKNOWN;
+ metadata.header_metadata_size = 0;
expect(lzma_info_metadata_set(info, NULL, &my_metadata, true, false)
== LZMA_OK);
expect(lzma_info_size_set(info, LZMA_INFO_HEADER_METADATA,