Skip to content

Commit 5956023

Browse files
committed
MP4: Fix panic on invalid hdlr atom size
1 parent 15e893e commit 5956023

File tree

4 files changed

+15
-0
lines changed

4 files changed

+15
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3030
- Fix panic when reading properties of a file with no timescale specified ([issue](https://github.com/Serial-ATA/lofty-rs/issues/418))
3131
- Fix panics when reading improperly sized freeform atom identifiers ([issue](https://github.com/Serial-ATA/lofty-rs/issues/425)) ([issue](https://github.com/Serial-ATA/lofty-rs/issues/426))
3232
- Fix panic when `data` atom length is less than 16 bytes ([issue](https://github.com/Serial-ATA/lofty-rs/issues/429))
33+
- Fix panic when `hdlr` atom is an unexpected length ([issue](https://github.com/Serial-ATA/lofty-rs/issues/435))
3334
- **WAV**:
3435
- Fix panic when reading properties with large written bytes per second ([issue](https://github.com/Serial-ATA/lofty-rs/issues/420))
3536
- Fix panic when reading an improperly sized INFO LIST ([issue](https://github.com/Serial-ATA/lofty-rs/issues/427))

lofty/src/mp4/properties.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,12 @@ where
244244
mdhd = Some(atom)
245245
},
246246
b"hdlr" => {
247+
if atom.len < 20 {
248+
log::warn!("Incomplete 'hdlr' atom, skipping");
249+
skip_unneeded(reader, atom.extended, atom.len)?;
250+
continue;
251+
}
252+
247253
// The hdlr atom is followed by 8 zeros
248254
reader.seek(SeekFrom::Current(8))?;
249255

lofty/tests/fuzz/mp4file_read_from.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,11 @@ fn panic3() {
3131
);
3232
let _ = Mp4File::read_from(&mut reader, ParseOptions::new());
3333
}
34+
35+
#[test]
36+
fn panic4() {
37+
let mut reader = crate::get_reader(
38+
"mp4file_read_from/steam_at_mention_IDX_83_RAND_107070306175668418039559.m4a",
39+
);
40+
let _ = Mp4File::read_from(&mut reader, ParseOptions::new());
41+
}

0 commit comments

Comments
 (0)