diff options
author | Lennart Poettering <lennart@poettering.net> | 2015-07-29 18:20:17 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2015-07-29 18:20:17 +0200 |
commit | 2b32ffa07dfb62385f82d073c9c2fff890ac1889 (patch) | |
tree | 21dcccfa6783a71e99b53bc3965297a8b6c8832d /src/libsystemd/sd-bus/bus-gvariant.c | |
parent | 4eb344b1b8478e9a99c727cf495aa13c4e608b00 (diff) | |
parent | 03ebf5e89bf63a32a2ffe253bec9e506f6917c80 (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.c | 21 |
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; |