1 diff --git a/src/pulsecore/iochannel.c b/src/pulsecore/iochannel.c
2 index 8ace297ff..897337522 100644
3 --- a/src/pulsecore/iochannel.c
4 +++ b/src/pulsecore/iochannel.c
5 @@ -355,7 +355,7 @@ ssize_t pa_iochannel_write_with_fds(pa_iochannel*io, const void*data, size_t l,
9 - uint8_t data[CMSG_SPACE(sizeof(int) * nfd)];
10 + uint8_t data[CMSG_SPACE(sizeof(int) * MAX_ANCIL_DATA_FDS)];
14 @@ -382,7 +382,13 @@ ssize_t pa_iochannel_write_with_fds(pa_iochannel*io, const void*data, size_t l,
17 mh.msg_control = &cmsg;
18 - mh.msg_controllen = sizeof(cmsg);
20 + /* If we followed the example on the cmsg man page, we'd use
21 + * sizeof(cmsg.data) here, but if nfd < MAX_ANCIL_DATA_FDS, then the data
22 + * buffer is larger than needed, and the kernel doesn't like it if we set
23 + * msg_controllen to a larger than necessary value. The commit message for
24 + * commit 451d1d6762 contains a longer explanation. */
25 + mh.msg_controllen = CMSG_SPACE(sizeof(int) * nfd);
27 if ((r = sendmsg(io->ofd, &mh, MSG_NOSIGNAL)) >= 0) {
28 io->writable = io->hungup = false;