[systemd-commits] src/libsystemd-bus

Lennart Poettering lennart at kemper.freedesktop.org
Mon Dec 23 14:48:57 PST 2013


 src/libsystemd-bus/bus-message.c       |    5 +++--
 src/libsystemd-bus/test-bus-gvariant.c |    5 +++--
 2 files changed, 6 insertions(+), 4 deletions(-)

New commits:
commit 8f19720dd2782684a0c73d1deb5e1ac3e1fb086d
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon Dec 23 23:48:30 2013 +0100

    bus: fix assert when serializing fixed size struct to gvariant

diff --git a/src/libsystemd-bus/bus-message.c b/src/libsystemd-bus/bus-message.c
index 39a85d5..9092a66 100644
--- a/src/libsystemd-bus/bus-message.c
+++ b/src/libsystemd-bus/bus-message.c
@@ -2055,7 +2055,7 @@ static int bus_message_close_struct(sd_bus_message *m, struct bus_container *c,
                                 return r;
                 }
 
-                assert(i <= c->n_offsets);
+                assert(!c->need_offsets || i <= c->n_offsets);
 
                 /* We need to add an offset for each item that has a
                  * variable size and that is not the last one in the
@@ -2067,7 +2067,8 @@ static int bus_message_close_struct(sd_bus_message *m, struct bus_container *c,
                 p += n;
         }
 
-        assert(i == c->n_offsets);
+        assert(!c->need_offsets || i == c->n_offsets);
+        assert(c->need_offsets || n_variable == 0);
 
         if (n_variable <= 0) {
                 a = message_extend_body(m, 1, 0, add_offset);
diff --git a/src/libsystemd-bus/test-bus-gvariant.c b/src/libsystemd-bus/test-bus-gvariant.c
index de9f001..cb07c96 100644
--- a/src/libsystemd-bus/test-bus-gvariant.c
+++ b/src/libsystemd-bus/test-bus-gvariant.c
@@ -141,9 +141,10 @@ static void test_marshal(void) {
         assert_se(sd_bus_message_new_method_call(bus, "a.service.name", "/an/object/path/which/is/really/really/long/so/that/we/hit/the/eight/bit/boundary/by/quite/some/margin/to/test/this/stuff/that/it/really/works", "an.interface.name", "AMethodName", &m) >= 0);
 
         assert_se(sd_bus_message_append(m,
-                                        "a(usv)", 2,
+                                        "a(usv)", 3,
                                         4711, "first-string-parameter", "(st)", "X", (uint64_t) 1111,
-                                        4712, "second-string-parameter", "(a(si))", 2, "Y", 5, "Z", 6) >= 0);
+                                        4712, "second-string-parameter", "(a(si))", 2, "Y", 5, "Z", 6,
+                                        4713, "third-string-parameter", "(uu)", 1, 2) >= 0);
 
         assert_se(bus_message_seal(m, 4711, 0) >= 0);
 



More information about the systemd-commits mailing list