summaryrefslogtreecommitdiff
path: root/src/libsystemd-bus/bus-message.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-12-02 15:28:20 +0100
committerLennart Poettering <lennart@poettering.net>2013-12-02 15:29:40 +0100
commit6717d473506800363af9d2bafbf263ee054e856d (patch)
treec25bf710e766bebf53d62303e7e52412de9dddde /src/libsystemd-bus/bus-message.c
parent99f37ad86e114b2d1c9eaedf2bc1a0004a265d26 (diff)
bus: when replying to an incoming message and the vtable contains the expected return signature generate an error if the response message doesn't match it
Diffstat (limited to 'src/libsystemd-bus/bus-message.c')
-rw-r--r--src/libsystemd-bus/bus-message.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/libsystemd-bus/bus-message.c b/src/libsystemd-bus/bus-message.c
index a1e6c9f973..dc85694471 100644
--- a/src/libsystemd-bus/bus-message.c
+++ b/src/libsystemd-bus/bus-message.c
@@ -568,6 +568,7 @@ static int message_new_reply(
}
t->dont_send = !!(call->header->flags & SD_BUS_MESSAGE_NO_REPLY_EXPECTED);
+ t->enforced_reply_signature = call->enforced_reply_signature;
*m = t;
return 0;
@@ -3962,6 +3963,13 @@ int bus_message_seal(sd_bus_message *m, uint64_t serial) {
if (m->poisoned)
return -ESTALE;
+ /* In vtables the return signature of method calls is listed,
+ * let's check if they match if this is a response */
+ if (m->header->type == SD_BUS_MESSAGE_METHOD_RETURN &&
+ m->enforced_reply_signature &&
+ !streq(strempty(m->root_container.signature), m->enforced_reply_signature))
+ return -ENOMSG;
+
/* If there's a non-trivial signature set, then add it in here */
if (!isempty(m->root_container.signature)) {
r = message_append_field_signature(m, SD_BUS_MESSAGE_HEADER_SIGNATURE, m->root_container.signature, NULL);