summaryrefslogtreecommitdiff
path: root/src/libsystemd/sd-bus
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-11-28 19:16:25 +0100
committerLennart Poettering <lennart@poettering.net>2014-11-28 20:29:44 +0100
commitd9fba533169b271d0e803016fea86fb57bc3f5ca (patch)
treeea15d699eb755e06b0a67c7cc4199945b5471c52 /src/libsystemd/sd-bus
parent1abe54d9a9292d746e5990843bbbc509984b7f2c (diff)
sd-bus: if a NULL signatures is passed to sd_bus_message_skip(), make it skip a single element of any type
Diffstat (limited to 'src/libsystemd/sd-bus')
-rw-r--r--src/libsystemd/sd-bus/bus-message.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/libsystemd/sd-bus/bus-message.c b/src/libsystemd/sd-bus/bus-message.c
index a4939b47c8..9fdf0d7e81 100644
--- a/src/libsystemd/sd-bus/bus-message.c
+++ b/src/libsystemd/sd-bus/bus-message.c
@@ -4450,13 +4450,32 @@ _public_ int sd_bus_message_skip(sd_bus_message *m, const char *types) {
assert_return(m, -EINVAL);
assert_return(m->sealed, -EPERM);
- assert_return(types, -EINVAL);
- if (isempty(types))
- return 0;
+ /* If types is NULL, read exactly one element */
+ if (!types) {
+ struct bus_container *c;
+ size_t l;
+
+ if (message_end_of_signature(m))
+ return -ENXIO;
+
+ if (message_end_of_array(m, m->rindex))
+ return 0;
+
+ c = message_get_container(m);
+
+ r = signature_element_length(c->signature + c->index, &l);
+ if (r < 0)
+ return r;
+
+ types = strndupa(c->signature + c->index, l);
+ }
switch (*types) {
+ case 0: /* Nothing to drop */
+ return 0;
+
case SD_BUS_TYPE_BYTE:
case SD_BUS_TYPE_BOOLEAN:
case SD_BUS_TYPE_INT16: