mirror of
https://github.com/systemd/systemd.git
synced 2024-11-02 19:21:53 +03:00
bus: fix allocation of body parts from memfd
This commit is contained in:
parent
bc7fd8cdbe
commit
9b05bc4866
@ -441,7 +441,7 @@ static int bus_kernel_make_message(sd_bus *bus, struct kdbus_msg *k, sd_bus_mess
|
|||||||
if (d->vec.size < sizeof(struct bus_header))
|
if (d->vec.size < sizeof(struct bus_header))
|
||||||
return -EBADMSG;
|
return -EBADMSG;
|
||||||
|
|
||||||
h = (struct bus_header*)UINT64_TO_PTR(d->vec.address);
|
h = UINT64_TO_PTR(d->vec.address);
|
||||||
}
|
}
|
||||||
|
|
||||||
n_payload++;
|
n_payload++;
|
||||||
@ -476,9 +476,6 @@ static int bus_kernel_make_message(sd_bus *bus, struct kdbus_msg *k, sd_bus_mess
|
|||||||
if (n_bytes != total)
|
if (n_bytes != total)
|
||||||
return -EBADMSG;
|
return -EBADMSG;
|
||||||
|
|
||||||
//if (n_payload > 2)
|
|
||||||
// return -EBADMSG;
|
|
||||||
|
|
||||||
r = bus_message_from_header(h, sizeof(struct bus_header), fds, n_fds, NULL, seclabel, 0, &m);
|
r = bus_message_from_header(h, sizeof(struct bus_header), fds, n_fds, NULL, seclabel, 0, &m);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
@ -553,7 +550,7 @@ static int bus_kernel_make_message(sd_bus *bus, struct kdbus_msg *k, sd_bus_mess
|
|||||||
log_debug("Got unknown field from kernel %llu", d->type);
|
log_debug("Got unknown field from kernel %llu", d->type);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((BUS_MESSAGE_FIELDS_SIZE(m) > 0 && !m->fields) || BUS_MESSAGE_SIZE(m) != idx) {
|
if ((BUS_MESSAGE_FIELDS_SIZE(m) > 0 && !m->fields)) {
|
||||||
sd_bus_message_unref(m);
|
sd_bus_message_unref(m);
|
||||||
return -EBADMSG;
|
return -EBADMSG;
|
||||||
}
|
}
|
||||||
@ -685,10 +682,10 @@ int bus_kernel_pop_memfd(sd_bus *bus, void **address, size_t *size) {
|
|||||||
return -ENOTSUP;
|
return -ENOTSUP;
|
||||||
|
|
||||||
if (bus->n_memfd_cache <= 0) {
|
if (bus->n_memfd_cache <= 0) {
|
||||||
int fd;
|
int fd, r;
|
||||||
|
|
||||||
fd = ioctl(bus->input_fd, KDBUS_CMD_MEMFD_NEW, &fd);
|
r = ioctl(bus->input_fd, KDBUS_CMD_MEMFD_NEW, &fd);
|
||||||
if (fd < 0)
|
if (r < 0)
|
||||||
return -errno;
|
return -errno;
|
||||||
|
|
||||||
*address = NULL;
|
*address = NULL;
|
||||||
|
@ -433,6 +433,9 @@ static sd_bus_message *message_new(sd_bus *bus, uint8_t type) {
|
|||||||
m->header->version = bus ? bus->message_version : 1;
|
m->header->version = bus ? bus->message_version : 1;
|
||||||
m->allow_fds = !bus || bus->can_fds || (bus->state != BUS_HELLO && bus->state != BUS_RUNNING);
|
m->allow_fds = !bus || bus->can_fds || (bus->state != BUS_HELLO && bus->state != BUS_RUNNING);
|
||||||
|
|
||||||
|
if (bus)
|
||||||
|
m->bus = sd_bus_ref(bus);
|
||||||
|
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user