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

Side by Side Diff: remoting/protocol/host_message_dispatcher.cc

Issue 7466004: Message validation in message dispatchers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 9 years, 5 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
« no previous file with comments | « remoting/protocol/host_control_sender.cc ('k') | remoting/protocol/host_stub.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/memory/ref_counted.h" 5 #include "base/memory/ref_counted.h"
6 #include "net/base/io_buffer.h" 6 #include "net/base/io_buffer.h"
7 #include "remoting/proto/control.pb.h" 7 #include "remoting/proto/control.pb.h"
8 #include "remoting/proto/event.pb.h" 8 #include "remoting/proto/event.pb.h"
9 #include "remoting/proto/internal.pb.h" 9 #include "remoting/proto/internal.pb.h"
10 #include "remoting/protocol/connection_to_client.h" 10 #include "remoting/protocol/connection_to_client.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 event_message_reader_->Init( 45 event_message_reader_->Init(
46 connection->session()->event_channel(), 46 connection->session()->event_channel(),
47 NewCallback(this, &HostMessageDispatcher::OnEventMessageReceived)); 47 NewCallback(this, &HostMessageDispatcher::OnEventMessageReceived));
48 control_message_reader_->Init( 48 control_message_reader_->Init(
49 connection->session()->control_channel(), 49 connection->session()->control_channel(),
50 NewCallback(this, &HostMessageDispatcher::OnControlMessageReceived)); 50 NewCallback(this, &HostMessageDispatcher::OnControlMessageReceived));
51 } 51 }
52 52
53 void HostMessageDispatcher::OnControlMessageReceived( 53 void HostMessageDispatcher::OnControlMessageReceived(
54 ControlMessage* message, Task* done_task) { 54 ControlMessage* message, Task* done_task) {
55 // TODO(sergeyu): Add message validation.
56 if (message->has_begin_session_request()) { 55 if (message->has_begin_session_request()) {
57 host_stub_->BeginSessionRequest( 56 const BeginSessionRequest& request = message->begin_session_request();
58 &message->begin_session_request().credentials(), done_task); 57 if (request.has_credentials() && request.credentials().has_type()) {
59 return; 58 host_stub_->BeginSessionRequest(&request.credentials(), done_task);
59 return;
60 }
60 } 61 }
61 if (message->has_suggest_resolution()) { 62
62 host_stub_->SuggestResolution(&message->suggest_resolution(), done_task);
63 return;
64 }
65 LOG(WARNING) << "Invalid control message received."; 63 LOG(WARNING) << "Invalid control message received.";
66 done_task->Run(); 64 done_task->Run();
67 delete done_task; 65 delete done_task;
68 } 66 }
69 67
70 void HostMessageDispatcher::OnEventMessageReceived( 68 void HostMessageDispatcher::OnEventMessageReceived(
71 EventMessage* message, Task* done_task) { 69 EventMessage* message, Task* done_task) {
72 // TODO(sergeyu): Add message validation.
73 connection_->UpdateSequenceNumber(message->sequence_number()); 70 connection_->UpdateSequenceNumber(message->sequence_number());
71
74 if (message->has_key_event()) { 72 if (message->has_key_event()) {
75 input_stub_->InjectKeyEvent(&message->key_event(), done_task); 73 const KeyEvent& event = message->key_event();
76 return; 74 if (event.has_keycode() && event.has_pressed()) {
77 } 75 input_stub_->InjectKeyEvent(&event, done_task);
78 if (message->has_mouse_event()) { 76 return;
77 }
78 } else if (message->has_mouse_event()) {
79 input_stub_->InjectMouseEvent(&message->mouse_event(), done_task); 79 input_stub_->InjectMouseEvent(&message->mouse_event(), done_task);
80 return; 80 return;
81 } 81 }
82
82 LOG(WARNING) << "Invalid event message received."; 83 LOG(WARNING) << "Invalid event message received.";
83 done_task->Run(); 84 done_task->Run();
84 delete done_task; 85 delete done_task;
85 } 86 }
86 87
87 } // namespace protocol 88 } // namespace protocol
88 } // namespace remoting 89 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/host_control_sender.cc ('k') | remoting/protocol/host_stub.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698