Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1595)

Unified Diff: remoting/base/decoder_verbatim.cc

Issue 3388024: Fix memory problem in DecoderVerbatim (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | remoting/base/decoder_verbatim_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/base/decoder_verbatim.cc
diff --git a/remoting/base/decoder_verbatim.cc b/remoting/base/decoder_verbatim.cc
index b944bbcaf15d6f9f68ae438104d431607de46c28..fd0b3d1070864b39df76f0dfc6cd4f74ae85d3ab 100644
--- a/remoting/base/decoder_verbatim.cc
+++ b/remoting/base/decoder_verbatim.cc
@@ -102,7 +102,20 @@ bool DecoderVerbatim::HandleRectData(ChromotingHostMessage* message) {
// Copy the data line by line.
const int src_stride = bytes_per_pixel_ * rect_width_;
const char* src =
- message->update_stream_packet().rect_data().data().c_str();
+ message->update_stream_packet().rect_data().data().data();
+
+ // Make sure there's enough data in |message|.
+ const int src_size =
+ message->update_stream_packet().rect_data().data().length();
+ if (src_size != src_stride * rect_height_)
+ return false;
+
+ // Make sure there's enough space for us to write to.
+ if (frame_->height() < static_cast<size_t>(rect_height_) ||
+ frame_->stride(media::VideoFrame::kRGBPlane) < src_stride) {
+ return false;
+ }
+
int src_stride_dir = src_stride;
if (reverse_rows_) {
// Copy rows from bottom to top to flip the image vertically.
« no previous file with comments | « no previous file | remoting/base/decoder_verbatim_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698