diff options
author | keybuk@chromium.org <keybuk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-01 04:01:05 +0000 |
---|---|---|
committer | keybuk@chromium.org <keybuk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-01 04:01:05 +0000 |
commit | 4d97f2337eacef834e523a6a8462d13ad4fbd550 (patch) | |
tree | 76432bbe637fafc3ce4e9a99fe796223ee47e95b /dbus/object_proxy.cc | |
parent | 3511b6ec1e955578ddb6e90f0cc99f824e36026e (diff) | |
download | chromium_src-4d97f2337eacef834e523a6a8462d13ad4fbd550.zip chromium_src-4d97f2337eacef834e523a6a8462d13ad4fbd550.tar.gz chromium_src-4d97f2337eacef834e523a6a8462d13ad4fbd550.tar.bz2 |
dbus: verify object path of incoming signals
The existing behavior, while convenient for debugging, is wrong.
D-Bus will not call any further filter functions once one returns
DBUS_HANDLER_RESULT_HANDLED, in order for the next to be called a
filter must return DBUS_HANDLER_RESULT_NOT_YET_HANDLED if it does
not handle the incoming signal.
We also can't defer this to the signal function since we have to
post that to a different thread, and return values get hard.
Since object proxies are constructed per-path, and match common
interfaces and members, this means signals must be matched on an
object otherwise only the first registered object proxy for any
client will be called, and will be called for all signals.
BUG=chromium-os:27113
TEST=ran unit tests, and manually verified existing code that uses ConnectToSignal
Change-Id: Ia4cbc064dff0421a37fe4c4b7c719acf25eb630c
Review URL: http://codereview.chromium.org/9508005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@124357 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'dbus/object_proxy.cc')
-rw-r--r-- | dbus/object_proxy.cc | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/dbus/object_proxy.cc b/dbus/object_proxy.cc index 32f6a60..0784ea7 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(); |