summaryrefslogtreecommitdiff
path: root/src/libsystemd-bus
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-12-12 19:58:46 +0100
committerLennart Poettering <lennart@poettering.net>2013-12-12 20:00:45 +0100
commit0f437184b687af58c5c4b2e3201a83d98485b0e4 (patch)
tree308a6b393307a15dc6b73b64d84658c39c9d4c7f /src/libsystemd-bus
parent9ff09bcb86fb125768667aca9bc0b10b1745370a (diff)
bus: enforce endianess and marshalling for messages we send
Diffstat (limited to 'src/libsystemd-bus')
-rw-r--r--src/libsystemd-bus/bus-internal.h1
-rw-r--r--src/libsystemd-bus/bus-kernel.c1
-rw-r--r--src/libsystemd-bus/bus-socket.c1
-rw-r--r--src/libsystemd-bus/sd-bus.c10
4 files changed, 9 insertions, 4 deletions
diff --git a/src/libsystemd-bus/bus-internal.h b/src/libsystemd-bus/bus-internal.h
index 1be7488ab9..df9a0b571c 100644
--- a/src/libsystemd-bus/bus-internal.h
+++ b/src/libsystemd-bus/bus-internal.h
@@ -147,6 +147,7 @@ struct sd_bus {
enum bus_state state;
int input_fd, output_fd;
int message_version;
+ int message_endian;
bool is_kernel:1;
bool can_fds:1;
diff --git a/src/libsystemd-bus/bus-kernel.c b/src/libsystemd-bus/bus-kernel.c
index c5817a78d6..68d0f48bd0 100644
--- a/src/libsystemd-bus/bus-kernel.c
+++ b/src/libsystemd-bus/bus-kernel.c
@@ -363,6 +363,7 @@ int bus_kernel_take_fd(sd_bus *b) {
b->bus_client = true;
b->can_fds = !!(hello.conn_flags & KDBUS_HELLO_ACCEPT_FD);
b->message_version = 2;
+ b->message_endian = BUS_NATIVE_ENDIAN;
/* the kernel told us the UUID of the underlying bus */
memcpy(b->server_id.bytes, hello.id128, sizeof(b->server_id.bytes));
diff --git a/src/libsystemd-bus/bus-socket.c b/src/libsystemd-bus/bus-socket.c
index a449ce0eb3..1365092d73 100644
--- a/src/libsystemd-bus/bus-socket.c
+++ b/src/libsystemd-bus/bus-socket.c
@@ -625,6 +625,7 @@ int bus_socket_setup(sd_bus *b) {
b->is_kernel = false;
b->message_version = 1;
+ b->message_endian = 0;
return 0;
}
diff --git a/src/libsystemd-bus/sd-bus.c b/src/libsystemd-bus/sd-bus.c
index 37408cf7b4..1a60356311 100644
--- a/src/libsystemd-bus/sd-bus.c
+++ b/src/libsystemd-bus/sd-bus.c
@@ -1280,7 +1280,12 @@ static int bus_seal_message(sd_bus *b, sd_bus_message *m) {
assert(b);
assert(m);
- if (m->header->version > b->message_version)
+ if (b->message_version != 0 &&
+ m->header->version != b->message_version)
+ return -EPERM;
+
+ if (b->message_endian != 0 &&
+ m->header->endian != b->message_endian)
return -EPERM;
if (m->sealed) {
@@ -1298,9 +1303,6 @@ int bus_seal_synthetic_message(sd_bus *b, sd_bus_message *m) {
assert(b);
assert(m);
- if (m->header->version > b->message_version)
- return -EPERM;
-
/* The bus specification says the serial number cannot be 0,
* hence let's fill something in for synthetic messages. Since
* synthetic messages might have a fake sender and we don't