in mp4parse/src/lib.rs [5405:5448]
fn read_hdlr<T: Read>(src: &mut BMFFBox<T>, strictness: ParseStrictness) -> Result<HandlerBox> {
if read_fullbox_version_no_flags(src)? != 0 {
return Status::HdlrUnsupportedVersion.into();
}
let pre_defined = be_u32(src)?;
if pre_defined != 0 {
fail_with_status_if(
strictness == ParseStrictness::Strict,
Status::HdlrPredefinedNonzero,
)?;
}
let handler_type = FourCC::from(be_u32(src)?);
for _ in 1..=3 {
let reserved = be_u32(src)?;
if reserved != 0 {
fail_with_status_if(
strictness == ParseStrictness::Strict,
Status::HdlrReservedNonzero,
)?;
}
}
match std::str::from_utf8(src.read_into_try_vec()?.as_slice()) {
Ok(name) => {
// `name` must be nul-terminated and any trailing bytes after the first nul ignored.
// See https://github.com/MPEGGroup/FileFormat/issues/35
if !name.bytes().any(|b| b == b'\0') {
fail_with_status_if(
strictness != ParseStrictness::Permissive,
Status::HdlrNameNoNul,
)?;
}
}
Err(_) => fail_with_status_if(
strictness != ParseStrictness::Permissive,
Status::HdlrNameNotUtf8,
)?,
}
Ok(HandlerBox { handler_type })
}