Commit 220be461 authored by David Staessens's avatar David Staessens Committed by Commit Bot

media/gpu/test: Fix video decoder tests reading out-of-bounds data from video.

This CL changes the video_decode_accelerator_(perf_)tests to not read data
beyond the end of the test video file, by adding proper bounds checking.

TEST=./video_decode_accelerator_tests \
  vda_sanity-vp90_2_17_show_existing_frame_20190109.vp9

BUG=None

Change-Id: I486eb6eb89fd13d9985ee518178b65dadf158e64
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1775944Reviewed-by: default avatarHirokazu Honda <hiroh@chromium.org>
Commit-Queue: Hirokazu Honda <hiroh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#693681}
parent 77bf3f4e
......@@ -157,6 +157,12 @@ std::string EncodedDataHelper::GetBytesForNextFrame() {
uint32_t frame_size = *reinterpret_cast<uint32_t*>(&data_[pos]);
pos += 12; // Skip frame header.
// Make sure we are not reading out of bounds.
if (pos + frame_size > data_.size()) {
LOG(ERROR) << "Unexpected data encountered while parsing frame";
next_pos_to_decode_ = data_.size();
return bytes;
}
bytes.append(data_.substr(pos, frame_size));
// Update next_pos_to_decode_.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment