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

@ -19,6 +19,7 @@
#include "libyuv/scale.h" // NOLINT
#include "libyuv/convert.h" // NOLINT
#include "webrtc/base/checks.h"
#include "webrtc/common.h"
#include "webrtc/common_types.h"
#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
@ -743,6 +744,13 @@ int VP8EncoderImpl::Encode(
return ret;
}
// Since we are extracting raw pointers from |input_image| to
// |raw_images_[0]|, the resolution of these frames must match. Note that
// |input_image| might be scaled from |frame|. In that case, the resolution of
// |raw_images_[0]| should have been updated in UpdateCodecFrameSize.
DCHECK_EQ(input_image.width(), static_cast<int>(raw_images_[0].d_w));
DCHECK_EQ(input_image.height(), static_cast<int>(raw_images_[0].d_h));
// Image in vpx_image_t format.
// Input image is const. VP8's raw image is not defined as const.
raw_images_[0].planes[VPX_PLANE_Y] =