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

Side by Side Diff: mojo/public/cpp/bindings/lib/message.cc

Issue 229683005: Validate MessageHeader before using (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove debug printfs Created 6 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "mojo/public/cpp/bindings/message.h" 5 #include "mojo/public/cpp/bindings/message.h"
6 6
7 #include <assert.h> 7 #include <assert.h>
8 #include <stdlib.h> 8 #include <stdlib.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
11 11
12 #include "mojo/public/cpp/bindings/lib/message_header_validator.h"
13
12 namespace mojo { 14 namespace mojo {
13 15
14 Message::Message() 16 Message::Message()
15 : data_num_bytes_(0), 17 : data_num_bytes_(0),
16 data_(NULL) { 18 data_(NULL) {
17 } 19 }
18 20
19 Message::~Message() { 21 Message::~Message() {
20 free(data_); 22 free(data_);
21 23
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 rv = ReadMessageRaw(handle, 68 rv = ReadMessageRaw(handle,
67 message.mutable_data(), 69 message.mutable_data(),
68 &num_bytes, 70 &num_bytes,
69 message.mutable_handles()->empty() 71 message.mutable_handles()->empty()
70 ? NULL 72 ? NULL
71 : reinterpret_cast<MojoHandle*>( 73 : reinterpret_cast<MojoHandle*>(
72 &message.mutable_handles()->front()), 74 &message.mutable_handles()->front()),
73 &num_handles, 75 &num_handles,
74 MOJO_READ_MESSAGE_FLAG_NONE); 76 MOJO_READ_MESSAGE_FLAG_NONE);
75 if (receiver && rv == MOJO_RESULT_OK) { 77 if (receiver && rv == MOJO_RESULT_OK) {
76 bool result = receiver->Accept(&message); 78 *receiver_result =
77 if (receiver_result) 79 internal::MessageHeaderValidator(receiver).Accept(&message);
78 *receiver_result = result;
79 } 80 }
80 81
81 return rv; 82 return rv;
82 } 83 }
83 84
84 } // namespace mojo 85 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/connector.cc ('k') | mojo/public/cpp/bindings/lib/message_header_validator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698