summaryrefslogtreecommitdiff
path: root/src/libsystemd/sd-bus
diff options
context:
space:
mode:
authorDavid Herrmann <dh.herrmann@gmail.com>2015-06-10 18:26:16 +0200
committerDavid Herrmann <dh.herrmann@gmail.com>2015-06-10 20:22:40 +0200
commit7cd4dbe9ca492eabc4c3821e1cb296649a967125 (patch)
tree0bf8e118e6af99c0dc7987563cbc0be96c16a848 /src/libsystemd/sd-bus
parenta8467435a0c4962cab89574f65e7318ef389351f (diff)
bus: fix bloom_add_prefixes() to add all required data
Lets look at an example where we add arg0="/foo/bar/waldo" to a bloom-filter. The following strings are added: "arg0:/foo/bar/waldo" "arg0-slash-prefix:/foo/bar" "arg0-slash-prefix:/foo" Two problems arise: 1) If we match on "arg0path=/foo/bar/waldo", the dbus-spec explicitly states that equal strings are also considered prefixes. However, in the bloom-match, we can only provide a single match-filter. Therefore, we have to add "arg0-slash-prefix:/foo/bar/waldo" there, but this never occured in the bloom-mask of the message. Hence, this patch makes sure bloom_add_prefixes() adds the full path as prefix, too. 2) If we match on "arg0path=/foo/", the dbus-spec states that arg0path does prefix-matching with the trailing slash _included_, unlike path_namespace= matches, which does *not* include them. This is inconsistent, but we have to support the specs. Therefore, we must add prefixes with _and_ without trailing separators. Hence, this patch makes sure bloom_add_prefixes() adds all prefixes with the trailing slash included. The final set of strings added therefore is: "arg0:/foo/bar/waldo" "arg0-slash-prefix:/foo/bar/waldo" "arg0-slash-prefix:/foo/bar/" "arg0-slash-prefix:/foo/bar" "arg0-slash-prefix:/foo/" "arg0-slash-prefix:/foo" "arg0-slash-prefix:/"
Diffstat (limited to 'src/libsystemd/sd-bus')
-rw-r--r--src/libsystemd/sd-bus/bus-bloom.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/libsystemd/sd-bus/bus-bloom.c b/src/libsystemd/sd-bus/bus-bloom.c
index 3556774074..91fab90cb0 100644
--- a/src/libsystemd/sd-bus/bus-bloom.c
+++ b/src/libsystemd/sd-bus/bus-bloom.c
@@ -116,11 +116,19 @@ void bloom_add_prefixes(uint64_t filter[], size_t size, unsigned k, const char *
p = stpcpy(stpcpy(c, a), ":");
strcpy(p, b);
+ bloom_add_data(filter, size, k, c, n);
+
for (;;) {
char *e;
e = strrchr(p, sep);
- if (!e || e == p)
+ if (!e)
+ break;
+
+ *(e + 1) = 0;
+ bloom_add_data(filter, size, k, c, e - c + 1);
+
+ if (e == p)
break;
*e = 0;