Skip to content

Commit f908f80

Browse files
Zaggy1024kinetiknz
authored andcommitted
Error on uuid boxes where the EOF falls within the UUID field
1 parent c1c61e7 commit f908f80

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

mp4parse/src/lib.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -2364,11 +2364,10 @@ fn read_box_header<T: ReadBytesExt>(src: &mut T) -> Result<Option<BoxHeader>> {
23642364
if count == 16 {
23652365
Some(buffer)
23662366
} else {
2367-
debug!("malformed uuid (short read), skipping");
2368-
None
2367+
debug!("malformed uuid (short read)");
2368+
return Err(Error::UnexpectedEOF);
23692369
}
23702370
} else {
2371-
debug!("malformed uuid, skipping");
23722371
None
23732372
}
23742373
} else {

mp4parse/src/tests.rs

+17
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,23 @@ fn read_box_header_truncated_uuid() {
166166
assert!(stream.head.uuid.is_none());
167167
}
168168

169+
#[test]
170+
fn read_box_header_uuid_past_eof() {
171+
const HEADER_UUID: [u8; 20] = [
172+
0x00, 0x00, 0x00, 0x18, // size = 24
173+
0x75, 0x75, 0x69, 0x64, // type = uuid
174+
0x85, 0xc0, 0xb6, 0x87, 0x82, 0x0f, 0x11, 0xe0, 0x81, 0x11, 0xf4, 0xce,
175+
];
176+
177+
let mut cursor = Cursor::new(HEADER_UUID);
178+
let mut iter = super::BoxIter::new(&mut cursor);
179+
match iter.next_box() {
180+
Err(Error::UnexpectedEOF) => (),
181+
Ok(_) => panic!("expected an error result"),
182+
_ => panic!("expected a different error result"),
183+
};
184+
}
185+
169186
#[test]
170187
fn read_ftyp() {
171188
let mut stream = make_box(BoxSize::Short(24), b"ftyp", |s| {

0 commit comments

Comments
 (0)