diff options
author | Lennart Poettering <lennart@poettering.net> | 2015-02-16 15:59:45 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2015-02-16 16:31:29 +0100 |
commit | b267a6d20464a138cae916a676f2c382c51d52de (patch) | |
tree | 69c2221dec6e7061a44e717994f1d2b556d6d83b /src/libsystemd | |
parent | 2ac7c17f9d8eeb403b91ee5a389562edaf47fb87 (diff) |
sd-bus: make sure we always serialize the reply cookie as 64bit on dbus2, and 32bit on dbus1
Diffstat (limited to 'src/libsystemd')
-rw-r--r-- | src/libsystemd/sd-bus/bus-kernel.c | 2 | ||||
-rw-r--r-- | src/libsystemd/sd-bus/bus-message.c | 28 |
2 files changed, 19 insertions, 11 deletions
diff --git a/src/libsystemd/sd-bus/bus-kernel.c b/src/libsystemd/sd-bus/bus-kernel.c index f6ef868e72..e90ee449d9 100644 --- a/src/libsystemd/sd-bus/bus-kernel.c +++ b/src/libsystemd/sd-bus/bus-kernel.c @@ -1152,7 +1152,7 @@ int bus_kernel_write_message(sd_bus *bus, sd_bus_message *m, bool hint_sync_call /* Anybody can send us invalid messages, let's just drop them. */ if (r == -EBADMSG || r == -EPROTOTYPE) - log_debug_errno(r, "Ignoring invalid message: %m"); + log_debug_errno(r, "Ignoring invalid synchronous reply: %m"); else return r; } diff --git a/src/libsystemd/sd-bus/bus-message.c b/src/libsystemd/sd-bus/bus-message.c index 447595764e..2959303033 100644 --- a/src/libsystemd/sd-bus/bus-message.c +++ b/src/libsystemd/sd-bus/bus-message.c @@ -413,6 +413,20 @@ static int message_append_field_uint64(sd_bus_message *m, uint64_t h, uint64_t x return 0; } +static int message_append_reply_cookie(sd_bus_message *m, uint64_t cookie) { + assert(m); + + if (BUS_MESSAGE_IS_GVARIANT(m)) + return message_append_field_uint64(m, BUS_MESSAGE_HEADER_REPLY_SERIAL, cookie); + else { + /* 64bit cookies are not supported on dbus1 */ + if (cookie > 0xffffffffUL) + return -ENOTSUP; + + return message_append_field_uint32(m, BUS_MESSAGE_HEADER_REPLY_SERIAL, (uint32_t) cookie); + } +} + int bus_message_from_header( sd_bus *bus, void *header, @@ -737,14 +751,7 @@ static int message_new_reply( if (t->reply_cookie == 0) return -ENOTSUP; - if (BUS_MESSAGE_IS_GVARIANT(t)) - r = message_append_field_uint64(t, BUS_MESSAGE_HEADER_REPLY_SERIAL, t->reply_cookie); - else { - if (t->reply_cookie > 0xffffffff) - return -ENOTSUP; - - r = message_append_field_uint32(t, BUS_MESSAGE_HEADER_REPLY_SERIAL, (uint32_t) t->reply_cookie); - } + r = message_append_reply_cookie(t, t->reply_cookie); if (r < 0) goto fail; @@ -898,7 +905,7 @@ int bus_message_new_synthetic_error( t->header->flags |= BUS_MESSAGE_NO_REPLY_EXPECTED; t->reply_cookie = cookie; - r = message_append_field_uint32(t, BUS_MESSAGE_HEADER_REPLY_SERIAL, (uint32_t) t->reply_cookie); + r = message_append_reply_cookie(t, t->reply_cookie); if (r < 0) goto fail; @@ -5818,7 +5825,8 @@ int bus_message_remarshal(sd_bus *bus, sd_bus_message **m) { return -ENOMEM; n->reply_cookie = (*m)->reply_cookie; - r = message_append_field_uint32(n, BUS_MESSAGE_HEADER_REPLY_SERIAL, (uint32_t) n->reply_cookie); + + r = message_append_reply_cookie(n, n->reply_cookie); if (r < 0) return r; |