1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-23 17:34:00 +03:00

sd-bus: socket - only transmit auxillary FDs once (#6603)

If a message is too large to fit into the output buffer, it will be
transmitted to the kernel in several chunks. However, the FDs must
only ever be transmitted once or they will bereceived by the remote
end repeatedly.

The D-Bus specification disallows several sets of FDs attached to
one message, however, the reference implementation of D-Bus will
not reject such a message, rather it will reassign the duplicate
FDs to subsequent FD-carrying messages.

This attaches the FD array only to the first byte of the message.
This commit is contained in:
Tom Gundersen 2017-08-30 13:09:03 +02:00 committed by Lennart Poettering
parent 7817154d5a
commit f29eef2e90

View File

@ -799,7 +799,7 @@ int bus_socket_write_message(sd_bus *bus, sd_bus_message *m, size_t *idx) {
.msg_iovlen = m->n_iovec, .msg_iovlen = m->n_iovec,
}; };
if (m->n_fds > 0) { if (m->n_fds > 0 && *idx == 0) {
struct cmsghdr *control; struct cmsghdr *control;
mh.msg_control = control = alloca(CMSG_SPACE(sizeof(int) * m->n_fds)); mh.msg_control = control = alloca(CMSG_SPACE(sizeof(int) * m->n_fds));