File tree Expand file tree Collapse file tree 1 file changed +9
-14
lines changed
Expand file tree Collapse file tree 1 file changed +9
-14
lines changed Original file line number Diff line number Diff line change @@ -2348,19 +2348,8 @@ fn read_box_header<T: ReadBytesExt>(src: &mut T) -> Result<Option<BoxHeader>> {
23482348 return Err ( Error :: Unsupported ( "unknown sized box" ) ) ;
23492349 }
23502350 }
2351- 1 => {
2352- let size64 = be_u64 ( src) ?;
2353- if size64 < BoxHeader :: MIN_LARGE_SIZE {
2354- return Status :: BoxBadWideSize . into ( ) ;
2355- }
2356- size64
2357- }
2358- _ => {
2359- if u64:: from ( size32) < BoxHeader :: MIN_SIZE {
2360- return Status :: BoxBadSize . into ( ) ;
2361- }
2362- u64:: from ( size32)
2363- }
2351+ 1 => be_u64 ( src) ?,
2352+ _ => u64:: from ( size32) ,
23642353 } ;
23652354 trace ! ( "read_box_header: name: {:?}, size: {}" , name, size) ;
23662355 let mut offset = match size32 {
@@ -2385,7 +2374,13 @@ fn read_box_header<T: ReadBytesExt>(src: &mut T) -> Result<Option<BoxHeader>> {
23852374 } else {
23862375 None
23872376 } ;
2388- assert ! ( offset <= size || size == 0 ) ;
2377+ if size != 0 && offset > size {
2378+ if size32 == 1 {
2379+ return Err ( Error :: from ( Status :: BoxBadWideSize ) ) ;
2380+ } else {
2381+ return Err ( Error :: from ( Status :: BoxBadSize ) ) ;
2382+ }
2383+ }
23892384 Ok ( Some ( BoxHeader {
23902385 name,
23912386 size,
You can’t perform that action at this time.
0 commit comments