Skip to content

Commit 5ae0f66

Browse files
baumanjkinetiknz
authored andcommitted
Return an error if there are multiple decoder-specific descriptors
See https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=22366
1 parent 0cec19a commit 5ae0f66

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

mp4parse/src/lib.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1953,6 +1953,7 @@ fn read_stbl<T: Read>(f: &mut BMFFBox<T>, track: &mut Track) -> Result<()> {
19531953
}
19541954

19551955
/// Parse an ftyp box.
1956+
/// See ISO 14496-12:2015 § 4.3
19561957
fn read_ftyp<T: Read>(src: &mut BMFFBox<T>) -> Result<FileTypeBox> {
19571958
let major = be_u32(src)?;
19581959
let minor = be_u32(src)?;
@@ -2421,7 +2422,7 @@ fn find_descriptor(data: &[u8], esds: &mut ES_Descriptor) -> Result<()> {
24212422
let des = &mut Cursor::new(remains);
24222423
let tag = des.read_u8()?;
24232424

2424-
// See ISO 14496-1:2010 § 8.3.3 for interpreting size of exandable classes
2425+
// See ISO 14496-1:2010 § 8.3.3 for interpreting size of expandable classes
24252426

24262427
let mut end: u32 = 0; // It's u8 without declaration type that is incorrect.
24272428
// MSB of extend_or_len indicates more bytes, up to 4 bytes.
@@ -2627,7 +2628,11 @@ fn read_ds_descriptor(data: &[u8], esds: &mut ES_Descriptor) -> Result<()> {
26272628
esds.extended_audio_object_type = extended_audio_object_type;
26282629
esds.audio_sample_rate = Some(sample_frequency_value);
26292630
esds.audio_channel_count = Some(channel_counts);
2630-
assert!(esds.decoder_specific_data.is_empty());
2631+
if !esds.decoder_specific_data.is_empty() {
2632+
return Err(Error::InvalidData(
2633+
"There can be only one DecSpecificInfoTag descriptor",
2634+
));
2635+
}
26312636
esds.decoder_specific_data.extend_from_slice(data)?;
26322637

26332638
Ok(())

0 commit comments

Comments
 (0)