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

Unified Diff: dbus/object_proxy.cc

Issue 9508005: dbus: verify object path of incoming signals (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comment fixes Created 8 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « dbus/end_to_end_async_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dbus/object_proxy.cc
diff --git a/dbus/object_proxy.cc b/dbus/object_proxy.cc
index 32f6a600df9d2ccb986276daa029e6c763ed4ebc..0784ea7222a54385877606e0108aeb7f90134d5f 100644
--- a/dbus/object_proxy.cc
+++ b/dbus/object_proxy.cc
@@ -304,14 +304,10 @@ void ObjectProxy::ConnectToSignalInternal(
}
}
// Add a match rule so the signal goes through HandleMessage().
- //
- // We don't restrict the sender object path to be |object_path_| here,
- // to make it easy to test D-Bus signal handling with dbus-send, that
- // uses "/" as the sender object path. We can make the object path
- // restriction customizable when it becomes necessary.
const std::string match_rule =
- base::StringPrintf("type='signal', interface='%s'",
- interface_name.c_str());
+ base::StringPrintf("type='signal', interface='%s', path='%s'",
+ interface_name.c_str(),
+ object_path_.value().c_str());
// Add the match rule if we don't have it.
if (match_rules_.find(match_rule) == match_rules_.end()) {
@@ -366,6 +362,14 @@ DBusHandlerResult ObjectProxy::HandleMessage(
scoped_ptr<Signal> signal(
Signal::FromRawMessage(raw_message));
+ // Verify the signal comes from the object we're proxying for, this is
+ // our last chance to return DBUS_HANDLER_RESULT_NOT_YET_HANDLED and
+ // allow other object proxies to handle instead.
+ const dbus::ObjectPath path = signal->GetPath();
+ if (path != object_path_) {
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+ }
+
const std::string interface = signal->GetInterface();
const std::string member = signal->GetMember();
« no previous file with comments | « dbus/end_to_end_async_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698