chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
sd-bus: deal with whitespace in matches
[elogind.git]
/
src
/
libsystemd
/
sd-bus
/
bus-match.c
diff --git
a/src/libsystemd/sd-bus/bus-match.c
b/src/libsystemd/sd-bus/bus-match.c
index 9e0769caa63dc08e6fa36f5f3f2ecc1802c2b477..0e92a85ef756fdaf177e8abdcf9c61394c5531dc 100644
(file)
--- a/
src/libsystemd/sd-bus/bus-match.c
+++ b/
src/libsystemd/sd-bus/bus-match.c
@@
-294,11
+294,17
@@
int bus_match_run(
sd_bus_slot *slot;
slot = container_of(node->leaf.callback, sd_bus_slot, match_callback);
sd_bus_slot *slot;
slot = container_of(node->leaf.callback, sd_bus_slot, match_callback);
- if (bus)
+ if (bus)
{
bus->current_slot = sd_bus_slot_ref(slot);
bus->current_slot = sd_bus_slot_ref(slot);
+ bus->current_handler = node->leaf.callback->callback;
+ bus->current_userdata = slot->userdata;
+ }
r = node->leaf.callback->callback(bus, m, slot->userdata, &error_buffer);
r = node->leaf.callback->callback(bus, m, slot->userdata, &error_buffer);
- if (bus)
+ if (bus) {
+ bus->current_userdata = NULL;
+ bus->current_handler = NULL;
bus->current_slot = sd_bus_slot_unref(slot);
bus->current_slot = sd_bus_slot_unref(slot);
+ }
r = bus_maybe_reply_error(m, r, &error_buffer);
if (r != 0)
r = bus_maybe_reply_error(m, r, &error_buffer);
if (r != 0)
@@
-444,13
+450,13
@@
static int bus_match_add_compare_value(
where->child = c;
if (t == BUS_MATCH_MESSAGE_TYPE) {
where->child = c;
if (t == BUS_MATCH_MESSAGE_TYPE) {
- c->compare.children = hashmap_new(
trivial_hash_func, trivial_compare_func
);
+ c->compare.children = hashmap_new(
NULL
);
if (!c->compare.children) {
r = -ENOMEM;
goto fail;
}
} else if (BUS_MATCH_CAN_HASH(t)) {
if (!c->compare.children) {
r = -ENOMEM;
goto fail;
}
} else if (BUS_MATCH_CAN_HASH(t)) {
- c->compare.children = hashmap_new(
string_hash_func, string_compare_func
);
+ c->compare.children = hashmap_new(
&string_hash_ops
);
if (!c->compare.children) {
r = -ENOMEM;
goto fail;
if (!c->compare.children) {
r = -ENOMEM;
goto fail;
@@
-531,7
+537,7
@@
static int bus_match_find_compare_value(
else if (BUS_MATCH_CAN_HASH(t))
n = hashmap_get(c->compare.children, value_str);
else {
else if (BUS_MATCH_CAN_HASH(t))
n = hashmap_get(c->compare.children, value_str);
else {
- for (n = c->child; !value_node_same(n, t, value_u8, value_str); n = n->next)
+ for (n = c->child;
n &&
!value_node_same(n, t, value_u8, value_str); n = n->next)
;
}
;
}
@@
-742,6
+748,9
@@
int bus_match_parse(
bool escaped = false, quoted;
uint8_t u;
bool escaped = false, quoted;
uint8_t u;
+ /* Avahi's match rules appear to include whitespace, skip over it */
+ p += strspn(p, " ");
+
eq = strchr(p, '=');
if (!eq)
return -EINVAL;
eq = strchr(p, '=');
if (!eq)
return -EINVAL;