summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-12-05 03:09:09 +0100
committerLennart Poettering <lennart@poettering.net>2013-12-05 03:09:09 +0100
commitea6ad56836bcbb09038eb1c0912e97dc8686b1d8 (patch)
tree7670e542453b555d61ff1106365a18f26cc03a76
parent2f671520ebade4877cbf6aca3572a5f8c4e1871d (diff)
bus: add missing LE meta data enforcement for gvariant serializer
-rw-r--r--src/libsystemd-bus/bus-message.c18
-rw-r--r--src/libsystemd-bus/test-bus-gvariant.c2
2 files changed, 10 insertions, 10 deletions
diff --git a/src/libsystemd-bus/bus-message.c b/src/libsystemd-bus/bus-message.c
index 73b0bab8f5..4c0e27f944 100644
--- a/src/libsystemd-bus/bus-message.c
+++ b/src/libsystemd-bus/bus-message.c
@@ -1912,7 +1912,7 @@ static int bus_message_close_array(sd_bus_message *m, struct bus_container *c) {
return -ENOMEM;
for (i = 0; i < c->n_offsets; i++) {
- uint16_t x = (uint16_t) (c->offsets[i] - c->begin);
+ uint16_t x = htole16((uint16_t) (c->offsets[i] - c->begin));
memcpy(a + (i*2), &x, 2);
}
@@ -1922,7 +1922,7 @@ static int bus_message_close_array(sd_bus_message *m, struct bus_container *c) {
return -ENOMEM;
for (i = 0; i < c->n_offsets; i++) {
- uint32_t x = (uint32_t) (c->offsets[i] - c->begin);
+ uint32_t x = htole32((uint32_t) (c->offsets[i] - c->begin));
memcpy(a + (i*4), &x, 4);
}
} else {
@@ -1931,7 +1931,7 @@ static int bus_message_close_array(sd_bus_message *m, struct bus_container *c) {
return -ENOMEM;
for (i = 0; i < c->n_offsets; i++) {
- uint64_t x = (uint64_t) (c->offsets[i] - c->begin);
+ uint64_t x = htole64((uint64_t) (c->offsets[i] - c->begin));
memcpy(a + (i*8), &x, 8);
}
}
@@ -2054,13 +2054,13 @@ static int bus_message_close_struct(sd_bus_message *m, struct bus_container *c,
if (z == 1)
((uint8_t*) a)[k] = (uint8_t) v;
else if (z == 2) {
- uint16_t x = (uint16_t) v;
+ uint16_t x = htole16((uint16_t) v);
memcpy(a + k * 2, &x, 2);
} else if (z == 4) {
- uint32_t x = (uint32_t) v;
+ uint32_t x = htole32((uint32_t) v);
memcpy(a + k * 4, &x, 4);
} else if (z == 8) {
- uint64_t x = (uint64_t) v;
+ uint64_t x = htole64((uint64_t) v);
memcpy(a + k * 8, &x, 8);
} else
assert_not_reached("Wrong offset width");
@@ -4392,13 +4392,13 @@ static int bus_message_close_header(sd_bus_message *m) {
if (z == 1)
((uint8_t*) a)[i] = (uint8_t) m->header_offsets[i];
else if (z == 2) {
- uint16_t x = (uint16_t) m->header_offsets[i];
+ uint16_t x = htole16((uint16_t) m->header_offsets[i]);
memcpy(a + 2*i, &x, 2);
} else if (z == 4) {
- uint32_t x = (uint32_t) m->header_offsets[i];
+ uint32_t x = htole32((uint32_t) m->header_offsets[i]);
memcpy(a + 4*i, &x, 4);
} else if (z == 8) {
- uint64_t x = (uint64_t) m->header_offsets[i];
+ uint64_t x = htole64((uint64_t) m->header_offsets[i]);
memcpy(a + 8*i, &x, 8);
} else
assert_not_reached("unknown type");
diff --git a/src/libsystemd-bus/test-bus-gvariant.c b/src/libsystemd-bus/test-bus-gvariant.c
index a5f8a17503..9888e33f5f 100644
--- a/src/libsystemd-bus/test-bus-gvariant.c
+++ b/src/libsystemd-bus/test-bus-gvariant.c
@@ -89,7 +89,7 @@ static void test_marshal(void) {
assert_se(sd_bus_open_system(&bus) >= 0);
bus->use_gvariant = true; /* dirty hack */
- assert_se(sd_bus_message_new_method_call(bus, "a.service.name", "/an/object/path", "an.interface.name", "AMethodName", &m) >= 0);
+ assert_se(sd_bus_message_new_method_call(bus, "a.service.name", "/an/object/path/which/is/really/really/long/so/that/we/hit/the/eight/bit/boundary/by/quite/some/margin/to/test/this/stuff/that/it/really/works", "an.interface.name", "AMethodName", &m) >= 0);
/* assert_se(sd_bus_message_append(m, "ssy(sts)v", "first-string-parameter", "second-string-parameter", 9, "a", (uint64_t) 7777, "b", "(su)", "xxx", 4712) >= 0); */
assert_se(sd_bus_message_append(m,