Bug 1407833 - update rust mp4 parser for add overflow. r?kinetik draft
authorAlfredo.Yang <ayang@mozilla.com>
Wed, 01 Nov 2017 14:48:15 +0800
changeset 689910 3513f096dbad4fe24e5cdd192a8f17c1c9b5a77a
parent 689820 ee21e5f7f1c1726e0ed2697eb45df54cdceedd36
child 738426 aab238f107dd746f7d55d1d885b5d81c88ca034a
push id87144
push userbmo:ayang@mozilla.com
push dateWed, 01 Nov 2017 06:49:10 +0000
reviewerskinetik
bugs1407833
milestone58.0a1
Bug 1407833 - update rust mp4 parser for add overflow. r?kinetik MozReview-Commit-ID: 8nGLWcXmGCr
media/libstagefright/binding/mp4parse_capi/src/lib.rs
media/libstagefright/binding/update-rust.sh
--- a/media/libstagefright/binding/mp4parse_capi/src/lib.rs
+++ b/media/libstagefright/binding/mp4parse_capi/src/lib.rs
@@ -836,17 +836,20 @@ impl<'a> Iterator for SampleToChunkItera
                     (Some(next), Some(peek)) if next.first_chunk > 0 && peek.first_chunk > 0 => {
                         self.sample_count = next.samples_per_chunk;
                         ((next.first_chunk - 1) .. (peek.first_chunk - 1))
                     },
                     (Some(next), None) if next.first_chunk > 0 => {
                         self.sample_count = next.samples_per_chunk;
                         // Total chunk number in 'stsc' could be different to 'stco',
                         // there could be more chunks at the last 'stsc' record.
-                        ((next.first_chunk - 1) .. next.first_chunk + self.remain_chunk_count -1)
+                        match next.first_chunk.checked_add(self.remain_chunk_count) {
+                            Some(r) => ((next.first_chunk - 1) .. r - 1),
+                            _ => (0 .. 0),
+                        }
                     },
                     _ => (0 .. 0),
                 };
 
                 self.remain_chunk_count.checked_sub(self.chunks.len() as u32).and_then(|res| {
                     self.remain_chunk_count = res;
                     self.chunks.next()
                 })
--- a/media/libstagefright/binding/update-rust.sh
+++ b/media/libstagefright/binding/update-rust.sh
@@ -1,13 +1,13 @@
 #!/bin/sh -e
 # Script to update mp4parse-rust sources to latest upstream
 
 # Default version.
-VER=7a10a8349b7dc098210deb0872de801e30f2d65e
+VER=cfeeab0036e14658f28f8df16c7ddede46ccf79a
 
 # Accept version or commit from the command line.
 if test -n "$1"; then
   VER=$1
 fi
 
 echo "Fetching sources..."
 rm -rf _upstream