diff options
author | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-21 00:19:21 +0000 |
---|---|---|
committer | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-21 00:19:21 +0000 |
commit | 8e0373faf29129998c520feafc3ad2b194343169 (patch) | |
tree | 251a3f4f8ed5629d66814d840cc03626c7fc8c41 /remoting/protocol | |
parent | b05a08b74150acf8fc021263355a7a3e0d389f6c (diff) | |
download | chromium_src-8e0373faf29129998c520feafc3ad2b194343169.zip chromium_src-8e0373faf29129998c520feafc3ad2b194343169.tar.gz chromium_src-8e0373faf29129998c520feafc3ad2b194343169.tar.bz2 |
Message validation in message dispatchers.
BUG=70335
TEST=None
Review URL: http://codereview.chromium.org/7466004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@93296 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/protocol')
-rw-r--r-- | remoting/protocol/client_control_sender.cc | 7 | ||||
-rw-r--r-- | remoting/protocol/client_control_sender.h | 5 | ||||
-rw-r--r-- | remoting/protocol/client_message_dispatcher.cc | 21 | ||||
-rw-r--r-- | remoting/protocol/client_stub.h | 2 | ||||
-rw-r--r-- | remoting/protocol/host_control_sender.cc | 7 | ||||
-rw-r--r-- | remoting/protocol/host_control_sender.h | 2 | ||||
-rw-r--r-- | remoting/protocol/host_message_dispatcher.cc | 27 | ||||
-rw-r--r-- | remoting/protocol/host_stub.h | 3 | ||||
-rw-r--r-- | remoting/protocol/protocol_mock_objects.h | 2 |
9 files changed, 26 insertions, 50 deletions
diff --git a/remoting/protocol/client_control_sender.cc b/remoting/protocol/client_control_sender.cc index dbefa21..c9d2d6f 100644 --- a/remoting/protocol/client_control_sender.cc +++ b/remoting/protocol/client_control_sender.cc @@ -24,13 +24,6 @@ ClientControlSender::ClientControlSender(net::Socket* socket) ClientControlSender::~ClientControlSender() { } -void ClientControlSender::NotifyResolution( - const NotifyResolutionRequest* msg, Task* done) { - protocol::ControlMessage message; - message.mutable_notify_resolution()->CopyFrom(*msg); - buffered_writer_->Write(SerializeAndFrameMessage(message), done); -} - void ClientControlSender::BeginSessionResponse(const LocalLoginStatus* msg, Task* done) { protocol::ControlMessage message; diff --git a/remoting/protocol/client_control_sender.h b/remoting/protocol/client_control_sender.h index 763ae9a..e53ef2c 100644 --- a/remoting/protocol/client_control_sender.h +++ b/remoting/protocol/client_control_sender.h @@ -13,6 +13,7 @@ #define REMOTING_PROTOCOL_CLIENT_STUB_IMPL_H_ #include "base/basictypes.h" +#include "base/compiler_specific.h" #include "base/memory/ref_counted.h" #include "remoting/protocol/client_stub.h" @@ -35,10 +36,8 @@ class ClientControlSender : public ClientStub { explicit ClientControlSender(net::Socket* socket); virtual ~ClientControlSender(); - virtual void NotifyResolution(const NotifyResolutionRequest* msg, - Task* done); virtual void BeginSessionResponse(const LocalLoginStatus* msg, - Task* done); + Task* done) OVERRIDE; // Stop writing. Must be called on the network thread when the // underlying socket is being destroyed. diff --git a/remoting/protocol/client_message_dispatcher.cc b/remoting/protocol/client_message_dispatcher.cc index e0c2758..68bf4617 100644 --- a/remoting/protocol/client_message_dispatcher.cc +++ b/remoting/protocol/client_message_dispatcher.cc @@ -39,19 +39,18 @@ void ClientMessageDispatcher::Initialize( void ClientMessageDispatcher::OnControlMessageReceived( ControlMessage* message, Task* done_task) { - // TODO(sergeyu): Add message validation. - if (message->has_notify_resolution()) { - client_stub_->NotifyResolution( - &message->notify_resolution(), done_task); - return; - } else if (message->has_begin_session_response()) { - client_stub_->BeginSessionResponse( - &message->begin_session_response().login_status(), done_task); - return; - } else { - LOG(WARNING) << "Invalid control message received."; + if (message->has_begin_session_response()) { + const BeginSessionResponse& response = message->begin_session_response(); + if (response.has_login_status() && + response.login_status().has_success()) { + client_stub_->BeginSessionResponse( + &response.login_status(), done_task); + return; + } } + LOG(WARNING) << "Invalid control message received."; + done_task->Run(); delete done_task; } diff --git a/remoting/protocol/client_stub.h b/remoting/protocol/client_stub.h index 4a75e05..21b3219 100644 --- a/remoting/protocol/client_stub.h +++ b/remoting/protocol/client_stub.h @@ -25,8 +25,6 @@ class ClientStub { ClientStub() {} virtual ~ClientStub() {} - virtual void NotifyResolution(const NotifyResolutionRequest* msg, - Task* done) = 0; virtual void BeginSessionResponse(const LocalLoginStatus* msg, Task* done) = 0; diff --git a/remoting/protocol/host_control_sender.cc b/remoting/protocol/host_control_sender.cc index 44cfceda4..6acc940 100644 --- a/remoting/protocol/host_control_sender.cc +++ b/remoting/protocol/host_control_sender.cc @@ -24,13 +24,6 @@ HostControlSender::HostControlSender(net::Socket* socket) HostControlSender::~HostControlSender() { } -void HostControlSender::SuggestResolution( - const SuggestResolutionRequest* msg, Task* done) { - protocol::ControlMessage message; - message.mutable_suggest_resolution()->CopyFrom(*msg); - buffered_writer_->Write(SerializeAndFrameMessage(message), done); -} - void HostControlSender::BeginSessionRequest(const LocalLoginCredentials* msg, Task* done) { protocol::ControlMessage message; diff --git a/remoting/protocol/host_control_sender.h b/remoting/protocol/host_control_sender.h index a0eea33..b1b88de 100644 --- a/remoting/protocol/host_control_sender.h +++ b/remoting/protocol/host_control_sender.h @@ -35,8 +35,6 @@ class HostControlSender : public HostStub { explicit HostControlSender(net::Socket* socket); virtual ~HostControlSender(); - virtual void SuggestResolution( - const SuggestResolutionRequest* msg, Task* done); virtual void BeginSessionRequest( const LocalLoginCredentials* credentials, Task* done); diff --git a/remoting/protocol/host_message_dispatcher.cc b/remoting/protocol/host_message_dispatcher.cc index 807234e..c2b6423 100644 --- a/remoting/protocol/host_message_dispatcher.cc +++ b/remoting/protocol/host_message_dispatcher.cc @@ -52,16 +52,14 @@ void HostMessageDispatcher::Initialize( void HostMessageDispatcher::OnControlMessageReceived( ControlMessage* message, Task* done_task) { - // TODO(sergeyu): Add message validation. if (message->has_begin_session_request()) { - host_stub_->BeginSessionRequest( - &message->begin_session_request().credentials(), done_task); - return; - } - if (message->has_suggest_resolution()) { - host_stub_->SuggestResolution(&message->suggest_resolution(), done_task); - return; + const BeginSessionRequest& request = message->begin_session_request(); + if (request.has_credentials() && request.credentials().has_type()) { + host_stub_->BeginSessionRequest(&request.credentials(), done_task); + return; + } } + LOG(WARNING) << "Invalid control message received."; done_task->Run(); delete done_task; @@ -69,16 +67,19 @@ void HostMessageDispatcher::OnControlMessageReceived( void HostMessageDispatcher::OnEventMessageReceived( EventMessage* message, Task* done_task) { - // TODO(sergeyu): Add message validation. connection_->UpdateSequenceNumber(message->sequence_number()); + if (message->has_key_event()) { - input_stub_->InjectKeyEvent(&message->key_event(), done_task); - return; - } - if (message->has_mouse_event()) { + const KeyEvent& event = message->key_event(); + if (event.has_keycode() && event.has_pressed()) { + input_stub_->InjectKeyEvent(&event, done_task); + return; + } + } else if (message->has_mouse_event()) { input_stub_->InjectMouseEvent(&message->mouse_event(), done_task); return; } + LOG(WARNING) << "Invalid event message received."; done_task->Run(); delete done_task; diff --git a/remoting/protocol/host_stub.h b/remoting/protocol/host_stub.h index 2a18ffe..52a7cf7c 100644 --- a/remoting/protocol/host_stub.h +++ b/remoting/protocol/host_stub.h @@ -17,15 +17,12 @@ namespace remoting { namespace protocol { class LocalLoginCredentials; -class SuggestResolutionRequest; class HostStub { public: HostStub() {}; virtual ~HostStub() {}; - virtual void SuggestResolution( - const SuggestResolutionRequest* msg, Task* done) = 0; virtual void BeginSessionRequest( const LocalLoginCredentials* credentials, Task* done) = 0; diff --git a/remoting/protocol/protocol_mock_objects.h b/remoting/protocol/protocol_mock_objects.h index 9b34b8e..199dd2d 100644 --- a/remoting/protocol/protocol_mock_objects.h +++ b/remoting/protocol/protocol_mock_objects.h @@ -70,8 +70,6 @@ class MockHostStub : public HostStub { MockHostStub(); ~MockHostStub(); - MOCK_METHOD2(SuggestResolution, void(const SuggestResolutionRequest* msg, - Task* done)); MOCK_METHOD2(BeginSessionRequest, void(const LocalLoginCredentials* credentials, Task* done)); |