1
0
Fork 0
mirror of https://github.com/alfg/mp4-rust.git synced 2024-05-19 16:58:04 +00:00

Prevent possible subtraction underflow

This commit is contained in:
Jensenn 2023-09-25 15:24:14 -06:00
parent fb694a602f
commit 85461b8272

View file

@ -103,7 +103,9 @@ impl<R: Read + Seek> ReadBox<&mut R> for SencBox {
// the senc box cannot be properly parsed without IV_size
// which is only available from other boxes. Store the raw
// data for parsing with member functions later
let data_size = start + size - reader.stream_position()?;
let data_size = (start + size)
.checked_sub(reader.stream_position()?)
.ok_or(Error::InvalidData("senc size too small"))?;
let mut sample_data = vec![0; data_size as usize];
reader.read_exact(&mut sample_data)?;