Bug 1448762 - P1. Handle Descriptor of type 80. r?kinetik draft
authorJean-Yves Avenard <jyavenard@mozilla.com>
Wed, 28 Mar 2018 19:28:52 +0200
changeset 773886 a7b0ede9394e3c959084610b608c0819b83d00d6
parent 773096 97cdd8febc40ac6025bce5dec9f8dadb8e62f906
child 773887 4575edb472218bd00da4fbfe6ce7735ebb6630c7
push id104345
push userbmo:jyavenard@mozilla.com
push dateWed, 28 Mar 2018 17:36:48 +0000
reviewerskinetik
bugs1448762
milestone61.0a1
Bug 1448762 - P1. Handle Descriptor of type 80. r?kinetik Some content present a descriptor of type 80 whose content is made of 0x80 too. Just skip over those when they are the last descriptor and don't error with EOF. MozReview-Commit-ID: Gvl1IenxiA0
media/mp4parse-rust/mp4parse/src/lib.rs
--- a/media/mp4parse-rust/mp4parse/src/lib.rs
+++ b/media/mp4parse-rust/mp4parse/src/lib.rs
@@ -1372,16 +1372,22 @@ fn find_descriptor(data: &[u8], esds: &m
     // Descriptor length should be more than 2 bytes.
     while remains.len() > 2 {
         let des = &mut Cursor::new(remains);
         let tag = des.read_u8()?;
 
         let mut end: u32 = 0;   // It's u8 without declaration type that is incorrect.
         // MSB of extend_or_len indicates more bytes, up to 4 bytes.
         for _ in 0..4 {
+            if (des.position() as usize) == remains.len() {
+                // There's nothing more to read, the 0x80 was actually part of
+                // the content, and not an extension size.
+                end = des.position() as u32;
+                break;
+            }
             let extend_or_len = des.read_u8()?;
             end = (end << 7) + (extend_or_len & 0x7F) as u32;
             if (extend_or_len & 0x80) == 0 {
                 end += des.position() as u32;
                 break;
             }
         };