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>> {
2348
2348
return Err ( Error :: Unsupported ( "unknown sized box" ) ) ;
2349
2349
}
2350
2350
}
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) ,
2364
2353
} ;
2365
2354
trace ! ( "read_box_header: name: {:?}, size: {}" , name, size) ;
2366
2355
let mut offset = match size32 {
@@ -2385,7 +2374,13 @@ fn read_box_header<T: ReadBytesExt>(src: &mut T) -> Result<Option<BoxHeader>> {
2385
2374
} else {
2386
2375
None
2387
2376
} ;
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
+ }
2389
2384
Ok ( Some ( BoxHeader {
2390
2385
name,
2391
2386
size,
You can’t perform that action at this time.
0 commit comments