mirror of
https://github.com/alfg/mp4-rust.git
synced 2024-06-02 13:39:54 +00:00
Prevent possible subtraction underflow
This commit is contained in:
parent
fb694a602f
commit
85461b8272
|
@ -103,7 +103,9 @@ impl<R: Read + Seek> ReadBox<&mut R> for SencBox {
|
||||||
// the senc box cannot be properly parsed without IV_size
|
// the senc box cannot be properly parsed without IV_size
|
||||||
// which is only available from other boxes. Store the raw
|
// which is only available from other boxes. Store the raw
|
||||||
// data for parsing with member functions later
|
// 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];
|
let mut sample_data = vec![0; data_size as usize];
|
||||||
reader.read_exact(&mut sample_data)?;
|
reader.read_exact(&mut sample_data)?;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue