File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed
Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -1297,15 +1297,21 @@ pub(crate) fn build_bmff_tree<R: Read + Seek + ?Sized>(
12971297 . map_err ( |err| Error :: InvalidAsset ( format ! ( "Bad BMFF {err}" ) ) ) ?;
12981298
12991299 // Break if size zero BoxHeader
1300- let s = header. size ;
1300+ let mut s = header. size ;
13011301 if s == 0 {
13021302 break ;
13031303 }
13041304
13051305 if current + s > end {
1306- return Err ( Error :: InvalidAsset (
1307- "Box size extends beyond asset bounds" . to_string ( ) ,
1308- ) ) ;
1306+ if BoxType :: MdatBox == header. name {
1307+ // for mdat boxes that extend beyond the end of the file we will just set the size to the remaining bytes in the file since
1308+ // some files have malformed mdat sizes but we can still hash the content by treating it as a truncated box
1309+ s = end - current;
1310+ } else {
1311+ return Err ( Error :: InvalidAsset (
1312+ "Box size extends beyond asset bounds" . to_string ( ) ,
1313+ ) ) ;
1314+ }
13091315 }
13101316
13111317 // Match and parse the supported atom boxes.
You can’t perform that action at this time.
0 commit comments