summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <smcv@collabora.com>2017-09-25 13:37:56 +0100
committerSimon McVittie <smcv@collabora.com>2017-09-25 13:37:56 +0100
commitbbbc6023180b58b4ebe0c09afd8df8cf950cdb3b (patch)
tree1194213b195cef5d4cd6087a7893dd2e462b578d
parent8f9022e8dc6f181ae7b7af975d818f82a2a85a57 (diff)
downloaddbus-bbbc6023180b58b4ebe0c09afd8df8cf950cdb3b.tar.gz
config-parser: Fail on impossible send_broadcast/send_destination pair
If we add a rule like <allow send_destination="com.example" send_broadcast="true"/> then it cannot possibly match anything, because to be a broadcast, the message would have to have no destination. The only value of send_destination that can be combined with send_broadcast="true" is the wildcard "*", but by this point in the function we already replaced "*" with NULL. Adapted from an earlier implementation of send_broadcast by Alban Crequy. Signed-off-by: Simon McVittie <smcv@collabora.com> Bug: https://bugs.freedesktop.org/92853 Reviewed-by: Philip Withnall <withnall@endlessm.com>
-rw-r--r--bus/config-parser.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/bus/config-parser.c b/bus/config-parser.c
index 7f095bd5..be27d38c 100644
--- a/bus/config-parser.c
+++ b/bus/config-parser.c
@@ -1554,6 +1554,19 @@ append_rule_from_element (BusConfigParser *parser,
return FALSE;
}
+ if (send_destination != NULL &&
+ send_broadcast != NULL &&
+ strcmp (send_broadcast, "true") == 0)
+ {
+ /* Broadcast messages have no destination, so this cannot
+ * possibly match */
+ dbus_set_error (error, DBUS_ERROR_FAILED,
+ "Rule with send_broadcast=\"true\" and "
+ "send_destination=\"%s\" cannot match anything",
+ send_destination);
+ return FALSE;
+ }
+
if (send_requested_reply &&
!(strcmp (send_requested_reply, "true") == 0 ||
strcmp (send_requested_reply, "false") == 0))