chiark / gitweb /
sd-bus: if a NULL signatures is passed to sd_bus_message_skip(), make it skip a singl...
authorLennart Poettering <lennart@poettering.net>
Fri, 28 Nov 2014 18:16:25 +0000 (19:16 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 28 Nov 2014 19:29:44 +0000 (20:29 +0100)
src/libsystemd/sd-bus/bus-message.c

index a4939b47c84b7189c81ecfd9399f80f6045eeec4..9fdf0d7e8117d842b6d98add0e893bf7bd676f76 100644 (file)
@@ -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: