termux-packages/packages/libpulseaudio/pulseaudio-discuss-iochannel-don-t-use-variable-length-array-in-union.patch
Alain Kalker a680abcbdf alsa-{lib,utils,plugins} and pulseaudio packages (#825)
* New package: libsndfile-1.0.27

* Bring back disabled package alsa-lib

* Bring back disabled package alsa-utils

* New disabled package: alsa-plugins-1.1.1

* New package: libpulseaudio-10.0, subpackage pulseaudio
2017-03-13 22:51:36 +01:00

29 lines
1.2 KiB
Diff

diff --git a/src/pulsecore/iochannel.c b/src/pulsecore/iochannel.c
index 8ace297ff..897337522 100644
--- a/src/pulsecore/iochannel.c
+++ b/src/pulsecore/iochannel.c
@@ -355,7 +355,7 @@ ssize_t pa_iochannel_write_with_fds(pa_iochannel*io, const void*data, size_t l,
struct iovec iov;
union {
struct cmsghdr hdr;
- uint8_t data[CMSG_SPACE(sizeof(int) * nfd)];
+ uint8_t data[CMSG_SPACE(sizeof(int) * MAX_ANCIL_DATA_FDS)];
} cmsg;
pa_assert(io);
@@ -382,7 +382,13 @@ ssize_t pa_iochannel_write_with_fds(pa_iochannel*io, const void*data, size_t l,
mh.msg_iov = &iov;
mh.msg_iovlen = 1;
mh.msg_control = &cmsg;
- mh.msg_controllen = sizeof(cmsg);
+
+ /* If we followed the example on the cmsg man page, we'd use
+ * sizeof(cmsg.data) here, but if nfd < MAX_ANCIL_DATA_FDS, then the data
+ * buffer is larger than needed, and the kernel doesn't like it if we set
+ * msg_controllen to a larger than necessary value. The commit message for
+ * commit 451d1d6762 contains a longer explanation. */
+ mh.msg_controllen = CMSG_SPACE(sizeof(int) * nfd);
if ((r = sendmsg(io->ofd, &mh, MSG_NOSIGNAL)) >= 0) {
io->writable = io->hungup = false;