summaryrefslogtreecommitdiff
path: root/src/libsystemd-bus/sd-bus.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-03-20 05:29:20 +0100
committerLennart Poettering <lennart@poettering.net>2013-03-20 23:00:10 +0100
commit80a46c7313b8fc4682881cb3a2ca9e4d743fcb2b (patch)
tree20ebf80690e694bf13eb484f7993e73c3328e5a5 /src/libsystemd-bus/sd-bus.c
parent9a17484d986f6cb8828afdf911db425b574c63fd (diff)
bus: demarshal header fields properly
Diffstat (limited to 'src/libsystemd-bus/sd-bus.c')
-rw-r--r--src/libsystemd-bus/sd-bus.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/src/libsystemd-bus/sd-bus.c b/src/libsystemd-bus/sd-bus.c
index 3f23da6ff5..70288ee131 100644
--- a/src/libsystemd-bus/sd-bus.c
+++ b/src/libsystemd-bus/sd-bus.c
@@ -833,10 +833,6 @@ static int message_make(sd_bus *bus, size_t size, sd_bus_message **m) {
assert(m);
assert(bus->rbuffer_size >= size);
- t = new0(sd_bus_message, 1);
- if (!t)
- return -ENOMEM;
-
if (bus->rbuffer_size > size) {
b = memdup((const uint8_t*) bus->rbuffer + size, bus->rbuffer_size - size);
if (!b) {
@@ -845,13 +841,11 @@ static int message_make(sd_bus *bus, size_t size, sd_bus_message **m) {
}
}
- t->n_ref = 1;
-
- t->header = bus->rbuffer;
- t->free_header = true;
-
- t->fields = (uint8_t*) bus->rbuffer + sizeof(struct bus_header);
- t->body = (uint8_t*) bus->rbuffer + sizeof(struct bus_header) + ALIGN_TO(BUS_MESSAGE_BODY_SIZE(t), 8);
+ r = bus_message_from_malloc(bus->rbuffer, size, &t);
+ if (r < 0) {
+ free(b);
+ return r;
+ }
bus->rbuffer = b;
bus->rbuffer_size -= size;