VP8/9EncoderImpl::Encode: Check resolution of input I420VideoFrame

This CL adds checks in Encode to guard against memory reads out of bounds.

R=pbos@webrtc.org, stefan@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/46429008

Cr-Commit-Position: refs/heads/master@{#8750}
git-svn-id: http://webrtc.googlecode.com/svn/trunk@8750 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
magjed@webrtc.org
2015-03-17 12:27:26 +00:00
parent 0cb612b43b
commit e155dbeae9
3 changed files with 21 additions and 0 deletions

View File

@ -21,6 +21,7 @@
#include "vpx/vp8cx.h"
#include "vpx/vp8dx.h"
#include "webrtc/base/checks.h"
#include "webrtc/common.h"
#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
#include "webrtc/modules/interface/module_common_types.h"
@ -265,6 +266,8 @@ int VP9EncoderImpl::Encode(const I420VideoFrame& input_image,
if (frame_types && frame_types->size() > 0) {
frame_type = (*frame_types)[0];
}
DCHECK_EQ(input_image.width(), static_cast<int>(raw_->d_w));
DCHECK_EQ(input_image.height(), static_cast<int>(raw_->d_h));
// Image in vpx_image_t format.
// Input image is const. VPX's raw image is not defined as const.
raw_->planes[VPX_PLANE_Y] = const_cast<uint8_t*>(input_image.buffer(kYPlane));