Skip to content

Commit 9515fd8

Browse files
authored
Merge pull request mozilla#257 from mozilla/ossfuzz-28324
Check for overflow when calculating ipma index
2 parents c918d72 + 6a66fef commit 9515fd8

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

mp4parse/src/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2039,7 +2039,7 @@ fn read_ipma<T: Read>(
20392039
fn read_ipco<T: Read>(src: &mut BMFFBox<T>) -> Result<TryHashMap<u16, ItemProperty>> {
20402040
let mut properties = TryHashMap::with_capacity(1)?;
20412041

2042-
let mut index = 1; // ipma uses 1-based indexing
2042+
let mut index: u16 = 1; // ipma uses 1-based indexing
20432043
let mut iter = src.box_iter();
20442044
while let Some(mut b) = iter.next_box()? {
20452045
if let Some(property) = match b.head.name {
@@ -2053,7 +2053,9 @@ fn read_ipco<T: Read>(src: &mut BMFFBox<T>) -> Result<TryHashMap<u16, ItemProper
20532053
properties.insert(index, property)?;
20542054
}
20552055

2056-
index += 1; // must include ignored properties to have correct indexes
2056+
index = index
2057+
.checked_add(1) // must include ignored properties to have correct indexes
2058+
.ok_or(Error::InvalidData("ipco index overflow"))?;
20572059

20582060
check_parser_state!(b.content);
20592061
}

0 commit comments

Comments
 (0)