mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 21:07:34 +00:00
LibVideo: Check parsed superframe sizes when decoding VP9 frames
Make sure that the next parsed superframe size will not overflow the chunk data before splitting it out to decode a frame.
This commit is contained in:
parent
9d3074f72f
commit
bf014c4d20
1 changed files with 5 additions and 1 deletions
|
@ -29,9 +29,13 @@ DecoderErrorOr<void> Decoder::decode(Span<const u8> chunk_data)
|
||||||
size_t offset = 0;
|
size_t offset = 0;
|
||||||
|
|
||||||
for (auto superframe_size : superframe_sizes) {
|
for (auto superframe_size : superframe_sizes) {
|
||||||
|
auto checked_size = Checked<size_t>(superframe_size);
|
||||||
|
checked_size += offset;
|
||||||
|
if (checked_size.has_overflow() || checked_size.value() > chunk_data.size())
|
||||||
|
return DecoderError::with_description(DecoderErrorCategory::Corrupted, "Superframe size invalid"sv);
|
||||||
auto frame_data = chunk_data.slice(offset, superframe_size);
|
auto frame_data = chunk_data.slice(offset, superframe_size);
|
||||||
TRY(decode_frame(frame_data));
|
TRY(decode_frame(frame_data));
|
||||||
offset += superframe_size;
|
offset = checked_size.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue