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

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

Issue 273233002: Mojo cpp bindings: add support for validating incoming messages. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync and rebase 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/lib/message_header_validator.h" 5 #include "mojo/public/cpp/bindings/lib/message_header_validator.h"
6 6
7 #include "mojo/public/cpp/bindings/lib/bindings_serialization.h" 7 #include "mojo/public/cpp/bindings/lib/bindings_serialization.h"
8 8
9 namespace mojo { 9 namespace mojo {
10 namespace internal { 10 namespace internal {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 // These flags are mutually exclusive. 47 // These flags are mutually exclusive.
48 if ((header->flags & internal::kMessageExpectsResponse) && 48 if ((header->flags & internal::kMessageExpectsResponse) &&
49 (header->flags & internal::kMessageIsResponse)) 49 (header->flags & internal::kMessageIsResponse))
50 return false; 50 return false;
51 51
52 return true; 52 return true;
53 } 53 }
54 54
55 } // namespace 55 } // namespace
56 56
57 MessageHeaderValidator::MessageHeaderValidator(MessageReceiver* next) 57 MessageHeaderValidator::MessageHeaderValidator(MessageReceiver* sink)
58 : next_(next) { 58 : MessageFilter(sink) {
59 assert(next);
60 } 59 }
61 60
62 bool MessageHeaderValidator::Accept(Message* message) { 61 bool MessageHeaderValidator::Accept(Message* message) {
63 // Make sure the message header isn't truncated before we start to read it. 62 // Make sure the message header isn't truncated before we start to read it.
64 if (message->data_num_bytes() < sizeof(internal::MessageHeader) || 63 if (message->data_num_bytes() < sizeof(internal::MessageHeader) ||
65 message->data_num_bytes() < message->header()->num_bytes) { 64 message->data_num_bytes() < message->header()->num_bytes) {
66 return false; 65 return false;
67 } 66 }
68 67
69 if (!IsValidMessageHeader(message->header())) 68 if (!IsValidMessageHeader(message->header()))
70 return false; 69 return false;
71 70
72 return next_->Accept(message); 71 return sink_->Accept(message);
73 }
74
75 bool MessageHeaderValidator::AcceptWithResponder(Message* message,
76 MessageReceiver* responder) {
77 assert(false); // Not reached!
78 return false;
79 } 72 }
80 73
81 } // namespace internal 74 } // namespace internal
82 } // namespace mojo 75 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/message_header_validator.h ('k') | mojo/public/cpp/bindings/lib/router.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698