From 88fe224c8c3cf80ad48bb2b5ddd6e455b0a112d4 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sun, 14 Apr 2013 17:46:41 +0200 Subject: bus: always explicitly rewind read index before passing message to caller or callback --- src/libsystemd-bus/bus-match.c | 4 ++++ src/libsystemd-bus/sd-bus.c | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+) (limited to 'src') diff --git a/src/libsystemd-bus/bus-match.c b/src/libsystemd-bus/bus-match.c index 01434b33b5..501a38df70 100644 --- a/src/libsystemd-bus/bus-match.c +++ b/src/libsystemd-bus/bus-match.c @@ -251,6 +251,10 @@ int bus_match_run( node->leaf.last_iteration = bus->iteration_counter; } + r = sd_bus_message_rewind(m, true); + if (r < 0) + return r; + /* Run the callback. And then invoke siblings. */ assert(node->leaf.callback); r = node->leaf.callback(bus, ret, m, node->leaf.userdata); diff --git a/src/libsystemd-bus/sd-bus.c b/src/libsystemd-bus/sd-bus.c index f40958a26e..f2dd81235f 100644 --- a/src/libsystemd-bus/sd-bus.c +++ b/src/libsystemd-bus/sd-bus.c @@ -1584,6 +1584,10 @@ static int process_reply(sd_bus *bus, sd_bus_message *m) { if (c->timeout != 0) prioq_remove(bus->reply_callbacks_prioq, c, &c->prioq_idx); + r = sd_bus_message_rewind(m, true); + if (r < 0) + return r; + r = c->callback(bus, 0, m, c->userdata); free(c); @@ -1611,6 +1615,10 @@ static int process_filter(sd_bus *bus, sd_bus_message *m) { l->last_iteration = bus->iteration_counter; + r = sd_bus_message_rewind(m, true); + if (r < 0) + return r; + r = l->callback(bus, 0, m, l->userdata); if (r != 0) return r; @@ -1720,6 +1728,10 @@ static int process_object(sd_bus *bus, sd_bus_message *m) { c->last_iteration = bus->iteration_counter; + r = sd_bus_message_rewind(m, true); + if (r < 0) + return r; + r = c->callback(bus, 0, m, c->userdata); if (r != 0) return r; @@ -1746,6 +1758,10 @@ static int process_object(sd_bus *bus, sd_bus_message *m) { c->last_iteration = bus->iteration_counter; + r = sd_bus_message_rewind(m, true); + if (r < 0) + return r; + r = c->callback(bus, 0, m, c->userdata); if (r != 0) return r; @@ -1930,6 +1946,10 @@ static int process_running(sd_bus *bus, sd_bus_message **ret) { goto null_message; if (ret) { + r = sd_bus_message_rewind(m, true); + if (r < 0) + return r; + *ret = m; m = NULL; return 1; -- cgit v1.2.3-54-g00ecf