Commit 94386fde authored by Erik de Castro Lopo's avatar Erik de Castro Lopo
Browse files

libFLAC: Add metadata size checks to FLAC library

This follows on from the previous patch.

Patch-from: lvqcl <lvqcl.mail@gmail.com>
parent 516a7ad4
......@@ -2536,6 +2536,9 @@ FLAC__bool write_metadata_block_header_cb_(FLAC__IOHandle handle, FLAC__IOCallba
FLAC__byte buffer[FLAC__STREAM_METADATA_HEADER_LENGTH];
FLAC__ASSERT(block->length < (1u << FLAC__STREAM_METADATA_LENGTH_LEN));
/* double protection */
if(block->length >= (1u << FLAC__STREAM_METADATA_LENGTH_LEN))
return false;
buffer[0] = (block->is_last? 0x80 : 0) | (FLAC__byte)block->type;
pack_uint32_(block->length, buffer + 1, 3);
......
......@@ -65,6 +65,9 @@ FLAC__bool FLAC__add_metadata_block(const FLAC__StreamMetadata *metadata, FLAC__
i += vendor_string_length;
}
FLAC__ASSERT(i < (1u << FLAC__STREAM_METADATA_LENGTH_LEN));
/* double protection */
if(i >= (1u << FLAC__STREAM_METADATA_LENGTH_LEN))
return false;
if(!FLAC__bitwriter_write_raw_uint32(bw, i, FLAC__STREAM_METADATA_LENGTH_LEN))
return false;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment