summaryrefslogtreecommitdiffstats
path: root/remoting
diff options
context:
space:
mode:
authorsergeyu <sergeyu@chromium.org>2014-09-29 14:30:22 -0700
committerCommit bot <commit-bot@chromium.org>2014-09-29 21:32:29 +0000
commitc827ad1c743fa8eb5d33f609f6a1e1a317af7c1a (patch)
treedb03418be523dd355e708fc43628a8348511340d /remoting
parentb3558eef5f128ea7d042531054b2740dc1bb173b (diff)
downloadchromium_src-c827ad1c743fa8eb5d33f609f6a1e1a317af7c1a.zip
chromium_src-c827ad1c743fa8eb5d33f609f6a1e1a317af7c1a.tar.gz
chromium_src-c827ad1c743fa8eb5d33f609f6a1e1a317af7c1a.tar.bz2
Fix remoting NM hosts to verify that incoming messages are dictionaries.
After crrev.com/295851 the PipeMessagingChannel verifies that incoming messages are dictionaries and then passes them as base::Value to OnMessage() and then OnMessage() implementation static_cast<> them to base::DictionaryValue. This is fragile, and also it shouldn't be PipeMessagingChannel's responsibility to verify format of the messages it reads. Moved the check to OnMessage() implementations. Review URL: https://codereview.chromium.org/615543004 Cr-Commit-Position: refs/heads/master@{#297274}
Diffstat (limited to 'remoting')
-rw-r--r--remoting/host/it2me/it2me_native_messaging_host.cc6
-rw-r--r--remoting/host/native_messaging/pipe_messaging_channel.cc6
-rw-r--r--remoting/host/setup/me2me_native_messaging_host.cc6
3 files changed, 12 insertions, 6 deletions
diff --git a/remoting/host/it2me/it2me_native_messaging_host.cc b/remoting/host/it2me/it2me_native_messaging_host.cc
index eaede40..e56dd7a 100644
--- a/remoting/host/it2me/it2me_native_messaging_host.cc
+++ b/remoting/host/it2me/it2me_native_messaging_host.cc
@@ -87,6 +87,12 @@ void It2MeNativeMessagingHost::Start(const base::Closure& quit_closure) {
void It2MeNativeMessagingHost::OnMessage(scoped_ptr<base::Value> message) {
DCHECK(task_runner()->BelongsToCurrentThread());
+ if (message->GetType() != base::Value::TYPE_DICTIONARY) {
+ LOG(ERROR) << "Received a message that's not a dictionary.";
+ channel_->SendMessage(nullptr);
+ return;
+ }
+
scoped_ptr<base::DictionaryValue> message_dict(
static_cast<base::DictionaryValue*>(message.release()));
scoped_ptr<base::DictionaryValue> response(new base::DictionaryValue());
diff --git a/remoting/host/native_messaging/pipe_messaging_channel.cc b/remoting/host/native_messaging/pipe_messaging_channel.cc
index 0f3fe11..399bfa8 100644
--- a/remoting/host/native_messaging/pipe_messaging_channel.cc
+++ b/remoting/host/native_messaging/pipe_messaging_channel.cc
@@ -72,12 +72,6 @@ void PipeMessagingChannel::Start(EventHandler* event_handler) {
void PipeMessagingChannel::ProcessMessage(scoped_ptr<base::Value> message) {
DCHECK(CalledOnValidThread());
- if (message->GetType() != base::Value::TYPE_DICTIONARY) {
- LOG(ERROR) << "Expected DictionaryValue";
- Shutdown();
- return;
- }
-
if (event_handler_)
event_handler_->OnMessage(message.Pass());
}
diff --git a/remoting/host/setup/me2me_native_messaging_host.cc b/remoting/host/setup/me2me_native_messaging_host.cc
index bf3684fe..3d6cb3d 100644
--- a/remoting/host/setup/me2me_native_messaging_host.cc
+++ b/remoting/host/setup/me2me_native_messaging_host.cc
@@ -104,6 +104,12 @@ void Me2MeNativeMessagingHost::Start(
void Me2MeNativeMessagingHost::OnMessage(scoped_ptr<base::Value> message) {
DCHECK(thread_checker_.CalledOnValidThread());
+ if (message->GetType() != base::Value::TYPE_DICTIONARY) {
+ LOG(ERROR) << "Received a message that's not a dictionary.";
+ channel_->SendMessage(nullptr);
+ return;
+ }
+
scoped_ptr<base::DictionaryValue> message_dict(
static_cast<base::DictionaryValue*>(message.release()));
scoped_ptr<base::DictionaryValue> response(new base::DictionaryValue());