bus: don't calculate kmsg message too large
This commit is contained in:
parent
3583882c4f
commit
e86b80b834
|
@ -141,7 +141,6 @@ bool service_name_is_valid(const char *p) {
|
|||
return false;
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
bool member_name_is_valid(const char *p) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue