chiark / gitweb /
bus: don't calculate kmsg message too large
authorLennart Poettering <lennart@poettering.net>
Fri, 12 Apr 2013 19:43:50 +0000 (21:43 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 12 Apr 2013 19:43:50 +0000 (21:43 +0200)
src/libsystemd-bus/bus-internal.c
src/libsystemd-bus/bus-kernel.c
src/shared/macro.h

index 317f6a8a9cdea436647a59536b670fa6492236dc..df295539ac4afd34b2aefe5265836a9dfa9411cd 100644 (file)
@@ -141,7 +141,6 @@ bool service_name_is_valid(const char *p) {
                 return false;
 
         return true;
-
 }
 
 bool member_name_is_valid(const char *p) {
index dc6f5b99853bf349f2d39ce9eb962dabdc155cd9..878cd9c432f1b022d1098b167756b1915ac42fb2 100644 (file)
@@ -57,23 +57,27 @@ static void append_payload_vec(struct kdbus_msg_data **d, const void *p, size_t
         assert(p);
         assert(sz > 0);
 
+        *d = ALIGN8_PTR(*d);
+
         (*d)->size = offsetof(struct kdbus_msg_data, vec) + sizeof(struct kdbus_vec);
         (*d)->type = KDBUS_MSG_PAYLOAD_VEC;
         (*d)->vec.address = (uint64_t) p;
         (*d)->vec.size = sz;
 
-        *d = (struct kdbus_msg_data*) ((uint8_t*) *d + ALIGN8((*d)->size));
+        *d = (struct kdbus_msg_data*) ((uint8_t*) *d + (*d)->size);
 }
 
 static void append_destination(struct kdbus_msg_data **d, const char *s, size_t length) {
         assert(d);
         assert(d);
 
+        *d = ALIGN8_PTR(*d);
+
         (*d)->size = offsetof(struct kdbus_msg_data, str) + length + 1;
         (*d)->type = KDBUS_MSG_DST_NAME;
         memcpy((*d)->str, s, length + 1);
 
-        *d = (struct kdbus_msg_data*) ((uint8_t*) *d + ALIGN8((*d)->size));
+        *d = (struct kdbus_msg_data*) ((uint8_t*) *d + (*d)->size);
 }
 
 static int bus_message_setup_kmsg(sd_bus_message *m) {
index 84a453a8f27319778eca17e5bd3e26330860dea4..99dc733853ea0dd8abe37db98a26d85f7c59f94f 100644 (file)
@@ -65,6 +65,8 @@
 #error "Wut? Pointers are neither 4 nor 8 bytes long?"
 #endif
 
+#define ALIGN8_PTR(p) ((void*) ALIGN8((unsigned long) p))
+
 static inline size_t ALIGN_TO(size_t l, size_t ali) {
         return ((l + ali - 1) & ~(ali - 1));
 }