зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1388618 - update mp4 rust parser to fix invalid PSSH box. r=kinetik
MozReview-Commit-ID: FnbgeNiKdR1 --HG-- extra : rebase_source : 0e8a253fee61ca2f96b75066ed5d904716796e36
This commit is contained in:
Родитель
d5210f24bb
Коммит
f683a17096
|
@ -709,9 +709,8 @@ fn read_moov<T: Read>(f: &mut BMFFBox<T>, context: &mut MediaContext) -> Result<
|
|||
}
|
||||
|
||||
fn read_pssh<T: Read>(src: &mut BMFFBox<T>) -> Result<ProtectionSystemSpecificHeaderBox> {
|
||||
let mut box_content = Vec::with_capacity(src.head.size as usize);
|
||||
src.read_to_end(&mut box_content)?;
|
||||
|
||||
let len = src.bytes_left();
|
||||
let mut box_content = read_buf(src, len)?;
|
||||
let (system_id, kid, data) = {
|
||||
let pssh = &mut Cursor::new(box_content.as_slice());
|
||||
|
||||
|
@ -721,14 +720,14 @@ fn read_pssh<T: Read>(src: &mut BMFFBox<T>) -> Result<ProtectionSystemSpecificHe
|
|||
|
||||
let mut kid: Vec<ByteData> = Vec::new();
|
||||
if version > 0 {
|
||||
let count = be_i32(pssh)?;
|
||||
let count = be_u32_with_limit(pssh)?;
|
||||
for _ in 0..count {
|
||||
let item = read_buf(pssh, 16)?;
|
||||
kid.push(item);
|
||||
}
|
||||
}
|
||||
|
||||
let data_size = be_i32(pssh)? as usize;
|
||||
let data_size = be_u32_with_limit(pssh)? as usize;
|
||||
let data = read_buf(pssh, data_size)?;
|
||||
|
||||
(system_id, kid, data)
|
||||
|
|
|
@ -1103,3 +1103,28 @@ fn read_esds_invalid_descriptor() {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn read_invalid_pssh() {
|
||||
// invalid pssh header length
|
||||
let pssh =
|
||||
vec![
|
||||
0x00, 0x00, 0x00, 0x01, 0x70,
|
||||
0x73, 0x73, 0x68, 0x01, 0x00, 0x00, 0x00, 0x10,
|
||||
0x77, 0xef, 0xec, 0xc0, 0xb2, 0x4d, 0x02, 0xac,
|
||||
0xe3, 0x3c, 0x1e, 0x52, 0xe2, 0xfb, 0x4b, 0x00,
|
||||
0x00, 0x00, 0x02, 0x7e, 0x57, 0x1d, 0x01, 0x7e,
|
||||
];
|
||||
|
||||
let mut stream = make_box(BoxSize::Auto, b"moov", |s| {
|
||||
s.append_bytes(pssh.as_slice())
|
||||
});
|
||||
let mut iter = super::BoxIter::new(&mut stream);
|
||||
let mut stream = iter.next_box().unwrap().unwrap();
|
||||
let mut context = super::MediaContext::new();
|
||||
|
||||
match super::read_moov(&mut stream, &mut context) {
|
||||
Err(Error::InvalidData(s)) => assert_eq!(s, "read_buf size exceeds BUF_SIZE_LIMIT"),
|
||||
_ => panic!("unexpected result with invalid descriptor"),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# Script to update mp4parse-rust sources to latest upstream
|
||||
|
||||
# Default version.
|
||||
VER=f63b23d75ffa823d713a2a10724acd9cd6689ebc
|
||||
VER=81260ded506dce968716720e10544c510f37d222
|
||||
|
||||
# Accept version or commit from the command line.
|
||||
if test -n "$1"; then
|
||||
|
|
Загрузка…
Ссылка в новой задаче