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:
parent
0cb612b43b
commit
e155dbeae9
@ -616,6 +616,16 @@ class TestVp8Simulcast : public ::testing::Test {
|
||||
EXPECT_EQ(0, encoder_->InitEncode(&settings_, 1, 1200));
|
||||
encoder_->SetRates(settings_.startBitrate, 30);
|
||||
ExpectStreams(kKeyFrame, 1);
|
||||
// Resize |input_frame_| to the new resolution.
|
||||
half_width = (settings_.width + 1) / 2;
|
||||
input_frame_.CreateEmptyFrame(settings_.width, settings_.height,
|
||||
settings_.width, half_width, half_width);
|
||||
memset(input_frame_.buffer(kYPlane), 0,
|
||||
input_frame_.allocated_size(kYPlane));
|
||||
memset(input_frame_.buffer(kUPlane), 0,
|
||||
input_frame_.allocated_size(kUPlane));
|
||||
memset(input_frame_.buffer(kVPlane), 0,
|
||||
input_frame_.allocated_size(kVPlane));
|
||||
EXPECT_EQ(0, encoder_->Encode(input_frame_, NULL, &frame_types));
|
||||
}
|
||||
|
||||
|
@ -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] =
|
||||
|
@ -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));
|
||||
|
Loading…
x
Reference in New Issue
Block a user