@@ -47,10 +47,6 @@ pub mod unstable;
47
47
// Arbitrary buffer size limit used for raw read_bufs on a box.
48
48
const BUF_SIZE_LIMIT : u64 = 10 * 1024 * 1024 ;
49
49
50
- // Max table length. Calculating in worst case for one week long video, one
51
- // frame per table entry in 30 fps.
52
- const TABLE_SIZE_LIMIT : u32 = 30 * 60 * 60 * 24 * 7 ;
53
-
54
50
/// The 'mif1' brand indicates structural requirements on files
55
51
/// See HEIF (ISO 23008-12:2017) § 10.2.1
56
52
const MIF1_BRAND : FourCC = FourCC { value : * b"mif1" } ;
@@ -2958,14 +2954,14 @@ fn read_pssh<T: Read>(src: &mut BMFFBox<T>) -> Result<ProtectionSystemSpecificHe
2958
2954
2959
2955
let mut kid = TryVec :: < ByteData > :: new ( ) ;
2960
2956
if version > 0 {
2961
- let count = be_u32_with_limit ( pssh) ?;
2957
+ let count = be_u32 ( pssh) ?;
2962
2958
for _ in 0 ..count {
2963
2959
let item = read_buf ( pssh, 16 ) ?;
2964
2960
kid. push ( item) ?;
2965
2961
}
2966
2962
}
2967
2963
2968
- let data_size = be_u32_with_limit ( pssh) ?;
2964
+ let data_size = be_u32 ( pssh) ?;
2969
2965
let data = read_buf ( pssh, data_size. into ( ) ) ?;
2970
2966
2971
2967
( system_id, kid, data)
@@ -3296,7 +3292,7 @@ fn read_tkhd<T: Read>(src: &mut BMFFBox<T>) -> Result<TrackHeaderBox> {
3296
3292
/// See ISOBMFF (ISO 14496-12:2015) § 8.6.6
3297
3293
fn read_elst < T : Read > ( src : & mut BMFFBox < T > ) -> Result < EditListBox > {
3298
3294
let ( version, _) = read_fullbox_extra ( src) ?;
3299
- let edit_count = be_u32_with_limit ( src) ?;
3295
+ let edit_count = be_u32 ( src) ?;
3300
3296
let mut edits = TryVec :: with_capacity ( edit_count. to_usize ( ) ) ?;
3301
3297
for _ in 0 ..edit_count {
3302
3298
let ( segment_duration, media_time) = match version {
@@ -3372,7 +3368,7 @@ fn read_mdhd<T: Read>(src: &mut BMFFBox<T>) -> Result<MediaHeaderBox> {
3372
3368
/// See ISOBMFF (ISO 14496-12:2015) § 8.7.5
3373
3369
fn read_stco < T : Read > ( src : & mut BMFFBox < T > ) -> Result < ChunkOffsetBox > {
3374
3370
let ( _, _) = read_fullbox_extra ( src) ?;
3375
- let offset_count = be_u32_with_limit ( src) ?;
3371
+ let offset_count = be_u32 ( src) ?;
3376
3372
let mut offsets = TryVec :: with_capacity ( offset_count. to_usize ( ) ) ?;
3377
3373
for _ in 0 ..offset_count {
3378
3374
offsets. push ( be_u32 ( src) ?. into ( ) ) ?;
@@ -3388,7 +3384,7 @@ fn read_stco<T: Read>(src: &mut BMFFBox<T>) -> Result<ChunkOffsetBox> {
3388
3384
/// See ISOBMFF (ISO 14496-12:2015) § 8.7.5
3389
3385
fn read_co64 < T : Read > ( src : & mut BMFFBox < T > ) -> Result < ChunkOffsetBox > {
3390
3386
let ( _, _) = read_fullbox_extra ( src) ?;
3391
- let offset_count = be_u32_with_limit ( src) ?;
3387
+ let offset_count = be_u32 ( src) ?;
3392
3388
let mut offsets = TryVec :: with_capacity ( offset_count. to_usize ( ) ) ?;
3393
3389
for _ in 0 ..offset_count {
3394
3390
offsets. push ( be_u64 ( src) ?) ?;
@@ -3404,7 +3400,7 @@ fn read_co64<T: Read>(src: &mut BMFFBox<T>) -> Result<ChunkOffsetBox> {
3404
3400
/// See ISOBMFF (ISO 14496-12:2015) § 8.6.2
3405
3401
fn read_stss < T : Read > ( src : & mut BMFFBox < T > ) -> Result < SyncSampleBox > {
3406
3402
let ( _, _) = read_fullbox_extra ( src) ?;
3407
- let sample_count = be_u32_with_limit ( src) ?;
3403
+ let sample_count = be_u32 ( src) ?;
3408
3404
let mut samples = TryVec :: with_capacity ( sample_count. to_usize ( ) ) ?;
3409
3405
for _ in 0 ..sample_count {
3410
3406
samples. push ( be_u32 ( src) ?) ?;
@@ -3420,11 +3416,11 @@ fn read_stss<T: Read>(src: &mut BMFFBox<T>) -> Result<SyncSampleBox> {
3420
3416
/// See ISOBMFF (ISO 14496-12:2015) § 8.7.4
3421
3417
fn read_stsc < T : Read > ( src : & mut BMFFBox < T > ) -> Result < SampleToChunkBox > {
3422
3418
let ( _, _) = read_fullbox_extra ( src) ?;
3423
- let sample_count = be_u32_with_limit ( src) ?;
3419
+ let sample_count = be_u32 ( src) ?;
3424
3420
let mut samples = TryVec :: with_capacity ( sample_count. to_usize ( ) ) ?;
3425
3421
for _ in 0 ..sample_count {
3426
3422
let first_chunk = be_u32 ( src) ?;
3427
- let samples_per_chunk = be_u32_with_limit ( src) ?;
3423
+ let samples_per_chunk = be_u32 ( src) ?;
3428
3424
let sample_description_index = be_u32 ( src) ?;
3429
3425
samples. push ( SampleToChunk {
3430
3426
first_chunk,
@@ -3444,7 +3440,7 @@ fn read_stsc<T: Read>(src: &mut BMFFBox<T>) -> Result<SampleToChunkBox> {
3444
3440
fn read_ctts < T : Read > ( src : & mut BMFFBox < T > ) -> Result < CompositionOffsetBox > {
3445
3441
let ( version, _) = read_fullbox_extra ( src) ?;
3446
3442
3447
- let counts = be_u32_with_limit ( src) ?;
3443
+ let counts = be_u32 ( src) ?;
3448
3444
3449
3445
if src. bytes_left ( )
3450
3446
< counts
@@ -3462,7 +3458,7 @@ fn read_ctts<T: Read>(src: &mut BMFFBox<T>) -> Result<CompositionOffsetBox> {
3462
3458
// however, some buggy contents have negative value when version == 0.
3463
3459
// So we always use Version1 here.
3464
3460
0 ..=1 => {
3465
- let count = be_u32_with_limit ( src) ?;
3461
+ let count = be_u32 ( src) ?;
3466
3462
let offset = TimeOffsetVersion :: Version1 ( be_i32 ( src) ?) ;
3467
3463
( count, offset)
3468
3464
}
@@ -3486,7 +3482,7 @@ fn read_ctts<T: Read>(src: &mut BMFFBox<T>) -> Result<CompositionOffsetBox> {
3486
3482
fn read_stsz < T : Read > ( src : & mut BMFFBox < T > ) -> Result < SampleSizeBox > {
3487
3483
let ( _, _) = read_fullbox_extra ( src) ?;
3488
3484
let sample_size = be_u32 ( src) ?;
3489
- let sample_count = be_u32_with_limit ( src) ?;
3485
+ let sample_count = be_u32 ( src) ?;
3490
3486
let mut sample_sizes = TryVec :: new ( ) ;
3491
3487
if sample_size == 0 {
3492
3488
sample_sizes. reserve ( sample_count. to_usize ( ) ) ?;
@@ -3508,10 +3504,10 @@ fn read_stsz<T: Read>(src: &mut BMFFBox<T>) -> Result<SampleSizeBox> {
3508
3504
/// See ISOBMFF (ISO 14496-12:2015) § 8.6.1.2
3509
3505
fn read_stts < T : Read > ( src : & mut BMFFBox < T > ) -> Result < TimeToSampleBox > {
3510
3506
let ( _, _) = read_fullbox_extra ( src) ?;
3511
- let sample_count = be_u32_with_limit ( src) ?;
3507
+ let sample_count = be_u32 ( src) ?;
3512
3508
let mut samples = TryVec :: with_capacity ( sample_count. to_usize ( ) ) ?;
3513
3509
for _ in 0 ..sample_count {
3514
- let sample_count = be_u32_with_limit ( src) ?;
3510
+ let sample_count = be_u32 ( src) ?;
3515
3511
let sample_delta = be_u32 ( src) ?;
3516
3512
samples. push ( Sample {
3517
3513
sample_count,
@@ -4881,16 +4877,6 @@ fn be_u32<T: ReadBytesExt>(src: &mut T) -> Result<u32> {
4881
4877
src. read_u32 :: < byteorder:: BigEndian > ( ) . map_err ( From :: from)
4882
4878
}
4883
4879
4884
- /// Using in reading table size and return error if it exceeds limitation.
4885
- fn be_u32_with_limit < T : ReadBytesExt > ( src : & mut T ) -> Result < u32 > {
4886
- be_u32 ( src) . and_then ( |v| {
4887
- if v > TABLE_SIZE_LIMIT {
4888
- return Err ( Error :: OutOfMemory ) ;
4889
- }
4890
- Ok ( v)
4891
- } )
4892
- }
4893
-
4894
4880
fn be_u64 < T : ReadBytesExt > ( src : & mut T ) -> Result < u64 > {
4895
4881
src. read_u64 :: < byteorder:: BigEndian > ( ) . map_err ( From :: from)
4896
4882
}
0 commit comments