Skip to content

Commit 38aa6f7

Browse files
committed
Remove artificial allocation limit (BUF_SIZE_LIMIT).
These situations are now better handled via [`fallible_collections`](https://github.com/vcombey/fallible_collections).
1 parent c378c16 commit 38aa6f7

File tree

2 files changed

+0
-75
lines changed

2 files changed

+0
-75
lines changed

mp4parse/src/lib.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,6 @@ mod tests;
4444
#[cfg(feature = "unstable-api")]
4545
pub mod unstable;
4646

47-
// Arbitrary buffer size limit used for raw read_bufs on a box.
48-
const BUF_SIZE_LIMIT: u64 = 10 * 1024 * 1024;
49-
5047
/// The 'mif1' brand indicates structural requirements on files
5148
/// See HEIF (ISO 23008-12:2017) § 10.2.1
5249
const MIF1_BRAND: FourCC = FourCC { value: *b"mif1" };
@@ -4841,10 +4838,6 @@ fn skip<T: Read>(src: &mut T, bytes: u64) -> Result<()> {
48414838

48424839
/// Read size bytes into a Vector or return error.
48434840
fn read_buf<T: Read>(src: &mut T, size: u64) -> Result<TryVec<u8>> {
4844-
if size > BUF_SIZE_LIMIT {
4845-
return Err(Error::InvalidData("read_buf size exceeds BUF_SIZE_LIMIT"));
4846-
}
4847-
48484841
let buf = src.take(size).read_into_try_vec()?;
48494842
if buf.len().to_u64() != size {
48504843
return Err(Error::InvalidData("failed buffer read"));

mp4parse/src/tests.rs

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -802,57 +802,8 @@ fn read_alac() {
802802
assert!(r.is_ok());
803803
}
804804

805-
#[test]
806-
fn avcc_limit() {
807-
let mut stream = make_box(BoxSize::Auto, b"avc1", |s| {
808-
s.append_repeated(0, 6)
809-
.B16(1)
810-
.append_repeated(0, 16)
811-
.B16(320)
812-
.B16(240)
813-
.append_repeated(0, 14)
814-
.append_repeated(0, 32)
815-
.append_repeated(0, 4)
816-
.B32(0xffff_ffff)
817-
.append_bytes(b"avcC")
818-
.append_repeated(0, 100)
819-
});
820-
let mut iter = super::BoxIter::new(&mut stream);
821-
let mut stream = iter.next_box().unwrap().unwrap();
822-
match super::read_video_sample_entry(&mut stream) {
823-
Err(Error::InvalidData(s)) => assert_eq!(s, "read_buf size exceeds BUF_SIZE_LIMIT"),
824-
Ok(_) => panic!("expected an error result"),
825-
_ => panic!("expected a different error result"),
826-
}
827-
}
828-
829805
#[test]
830806
fn esds_limit() {
831-
let mut stream = make_box(BoxSize::Auto, b"mp4a", |s| {
832-
s.append_repeated(0, 6)
833-
.B16(1)
834-
.B32(0)
835-
.B32(0)
836-
.B16(2)
837-
.B16(16)
838-
.B16(0)
839-
.B16(0)
840-
.B32(48000 << 16)
841-
.B32(0xffff_ffff)
842-
.append_bytes(b"esds")
843-
.append_repeated(0, 100)
844-
});
845-
let mut iter = super::BoxIter::new(&mut stream);
846-
let mut stream = iter.next_box().unwrap().unwrap();
847-
match super::read_audio_sample_entry(&mut stream) {
848-
Err(Error::InvalidData(s)) => assert_eq!(s, "read_buf size exceeds BUF_SIZE_LIMIT"),
849-
Ok(_) => panic!("expected an error result"),
850-
_ => panic!("expected a different error result"),
851-
}
852-
}
853-
854-
#[test]
855-
fn esds_limit_2() {
856807
let mut stream = make_box(BoxSize::Auto, b"mp4a", |s| {
857808
s.append_repeated(0, 6)
858809
.B16(1)
@@ -1305,25 +1256,6 @@ fn read_esds_redundant_descriptor() {
13051256
}
13061257
}
13071258

1308-
#[test]
1309-
fn read_invalid_pssh() {
1310-
// invalid pssh header length
1311-
let pssh = vec![
1312-
0x00, 0x00, 0x00, 0x01, 0x70, 0x73, 0x73, 0x68, 0x01, 0x00, 0x00, 0x00, 0x10, 0x77, 0xef,
1313-
0xec, 0xc0, 0xb2, 0x4d, 0x02, 0xac, 0xe3, 0x3c, 0x1e, 0x52, 0xe2, 0xfb, 0x4b, 0x00, 0x00,
1314-
0x00, 0x02, 0x7e, 0x57, 0x1d, 0x01, 0x7e,
1315-
];
1316-
1317-
let mut stream = make_box(BoxSize::Auto, b"moov", |s| s.append_bytes(pssh.as_slice()));
1318-
let mut iter = super::BoxIter::new(&mut stream);
1319-
let mut stream = iter.next_box().unwrap().unwrap();
1320-
1321-
match super::read_moov(&mut stream, None) {
1322-
Err(Error::InvalidData(s)) => assert_eq!(s, "read_buf size exceeds BUF_SIZE_LIMIT"),
1323-
_ => panic!("unexpected result with invalid descriptor"),
1324-
}
1325-
}
1326-
13271259
#[test]
13281260
fn read_stsd_lpcm() {
13291261
// Extract from sample converted by ffmpeg.

0 commit comments

Comments
 (0)