diff options
author | David Herrmann <dh.herrmann@gmail.com> | 2015-07-28 16:46:51 +0200 |
---|---|---|
committer | Lukasz Skalski <l.skalski@samsung.com> | 2015-08-26 18:23:32 +0200 |
commit | ca2ae8969c6fc6b1b07a8413e035d05fa2e9ff18 (patch) | |
tree | 33d2eae8880c1a1fb98bb3c3fb10932b865038af | |
parent | e71311d66fe5bde28d0f6254e8ea9ef5af4c8c36 (diff) | |
download | systemd-ca2ae8969c6fc6b1b07a8413e035d05fa2e9ff18.tar.gz systemd-ca2ae8969c6fc6b1b07a8413e035d05fa2e9ff18.tar.bz2 systemd-ca2ae8969c6fc6b1b07a8413e035d05fa2e9ff18.zip |
sd-bus: don't assert() on valid signatures
Right now sd_bus_message_skip() will abort execution if passed a
signature of the unary type "()". Regardless whether this should be
supported or not, we really must not abort. Drop the incorrect assertion
and add a test-case for this.
Change-Id: Ide6cf4e3d4786c38227457356f2af2e97fd43bee
-rw-r--r-- | src/libsystemd/sd-bus/bus-message.c | 1 | ||||
-rw-r--r-- | src/libsystemd/sd-bus/test-bus-marshal.c | 8 |
2 files changed, 7 insertions, 2 deletions
diff --git a/src/libsystemd/sd-bus/bus-message.c b/src/libsystemd/sd-bus/bus-message.c index 3d6f8c20cc..e04f6e3811 100644 --- a/src/libsystemd/sd-bus/bus-message.c +++ b/src/libsystemd/sd-bus/bus-message.c @@ -4776,7 +4776,6 @@ _public_ int sd_bus_message_skip(sd_bus_message *m, const char *types) { r = sd_bus_message_skip(m, s); if (r < 0) return r; - assert(r != 0); r = sd_bus_message_exit_container(m); if (r < 0) diff --git a/src/libsystemd/sd-bus/test-bus-marshal.c b/src/libsystemd/sd-bus/test-bus-marshal.c index 746df7bf5c..5e0f120151 100644 --- a/src/libsystemd/sd-bus/test-bus-marshal.c +++ b/src/libsystemd/sd-bus/test-bus-marshal.c @@ -126,6 +126,9 @@ int main(int argc, char *argv[]) { r = sd_bus_message_append(m, "y(ty)y(yt)y", 8, 777, 7, 9, 77, 7777, 10); assert_se(r >= 0); + r = sd_bus_message_append(m, "()"); + assert_se(r >= 0); + r = sd_bus_message_append(m, "ba(ss)", 255, 3, "aaa", "1", "bbb", "2", "ccc", "3"); assert_se(r >= 0); @@ -263,6 +266,9 @@ int main(int argc, char *argv[]) { assert_se(r > 0); assert_se(v == 10); + r = sd_bus_message_read(m, "()"); + assert_se(r > 0); + r = sd_bus_message_read(m, "ba(ss)", &boolean, 3, &x, &y, &a, &b, &c, &d); assert_se(r > 0); assert_se(boolean); @@ -342,7 +348,7 @@ int main(int argc, char *argv[]) { assert_se(sd_bus_message_verify_type(m, 'a', "{yv}") > 0); - r = sd_bus_message_skip(m, "a{yv}y(ty)y(yt)y"); + r = sd_bus_message_skip(m, "a{yv}y(ty)y(yt)y()"); assert_se(r >= 0); assert_se(sd_bus_message_verify_type(m, 'b', NULL) > 0); |