summaryrefslogtreecommitdiff
path: root/src/libsystemd/sd-bus/bus-gvariant.c
diff options
context:
space:
mode:
authorDavid Herrmann <dh.herrmann@gmail.com>2015-07-28 18:16:16 +0200
committerDavid Herrmann <dh.herrmann@gmail.com>2015-07-29 16:38:14 +0200
commite53d21d00740a1dfc2090cb5f1ac29b11b2baa27 (patch)
tree630563cf6994110a735431fe1aedb84aceca9d97 /src/libsystemd/sd-bus/bus-gvariant.c
parent9a8fb5ae172f03c26618b8a75478417bec8c0dd2 (diff)
sd-bus: fix marshaling of unary type
The unary type has a fixed size of 1 in gvariant. Make sure we properly encode it as such. Right now, we encode/decode it as empty sequence.
Diffstat (limited to 'src/libsystemd/sd-bus/bus-gvariant.c')
-rw-r--r--src/libsystemd/sd-bus/bus-gvariant.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/libsystemd/sd-bus/bus-gvariant.c b/src/libsystemd/sd-bus/bus-gvariant.c
index 2d18a4e6c1..402d43d66d 100644
--- a/src/libsystemd/sd-bus/bus-gvariant.c
+++ b/src/libsystemd/sd-bus/bus-gvariant.c
@@ -75,14 +75,19 @@ int bus_gvariant_get_size(const char *signature) {
case SD_BUS_TYPE_STRUCT_BEGIN:
case SD_BUS_TYPE_DICT_ENTRY_BEGIN: {
- char t[n-1];
-
- memcpy(t, p + 1, n - 2);
- t[n - 2] = 0;
-
- r = bus_gvariant_get_size(t);
- if (r < 0)
- return r;
+ if (n == 2) {
+ /* unary type () has fixed size of 1 */
+ r = 1;
+ } else {
+ char t[n-1];
+
+ memcpy(t, p + 1, n - 2);
+ t[n - 2] = 0;
+
+ r = bus_gvariant_get_size(t);
+ if (r < 0)
+ return r;
+ }
sum += r;
break;