summaryrefslogtreecommitdiff
path: root/src/libsystemd/sd-bus/bus-gvariant.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-07-29 18:20:17 +0200
committerLennart Poettering <lennart@poettering.net>2015-07-29 18:20:17 +0200
commit2b32ffa07dfb62385f82d073c9c2fff890ac1889 (patch)
tree21dcccfa6783a71e99b53bc3965297a8b6c8832d /src/libsystemd/sd-bus/bus-gvariant.c
parent4eb344b1b8478e9a99c727cf495aa13c4e608b00 (diff)
parent03ebf5e89bf63a32a2ffe253bec9e506f6917c80 (diff)
Merge pull request #774 from dvdhrm/gvariant3
gvariant: fix encoding of unary type and root-variant (v3)
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;