From: Timo Sirainen Date: Fri, 20 Jun 2014 09:18:32 +0000 (+0300) Subject: lib: fd_recv() no longer checks for msghdr.msg_controllen X-Git-Tag: 2.2.14.rc1~355 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=87ddb4d9937eba89455583565488f5f72fda8a65;p=thirdparty%2Fdovecot%2Fcore.git lib: fd_recv() no longer checks for msghdr.msg_controllen It doesn't work at least in OpenBSD and Tru64, and apparently it shouldn't really be needed anyway, so don't bother with it. We'll still keep checking the cmsghdr since that appears to work everywhere now. --- diff --git a/src/lib/fdpass.c b/src/lib/fdpass.c index 38e910b33a..628e53ac7c 100644 --- a/src/lib/fdpass.c +++ b/src/lib/fdpass.c @@ -140,12 +140,6 @@ ssize_t fd_send(int handle, int send_fd, const void *data, size_t size) return sendmsg(handle, &msg, 0); } -#ifdef __osf__ -# define CHECK_MSG(msg) TRUE /* Tru64 */ -#else -# define CHECK_MSG(msg) ((msg).msg_controllen >= CMSG_SPACE(sizeof(int))) -#endif - #ifdef LINUX20 /* Linux 2.0.x doesn't set any cmsg fields. Note that this might make some attacks possible so don't do it unless you really have to. */ @@ -188,10 +182,10 @@ ssize_t fd_read(int handle, void *data, size_t size, int *fd) /* at least one byte transferred - we should have the fd now. do extra checks to make sure it really is an fd that is being transferred to avoid potential DoS conditions. some systems don't - set all these values correctly however so CHECK_MSG() and - CHECK_CMSG() are somewhat system dependent */ + set all these values correctly however so CHECK_CMSG() is somewhat + system dependent */ cmsg = CMSG_FIRSTHDR(&msg); - if (!CHECK_MSG(msg) || !CHECK_CMSG(cmsg)) + if (!CHECK_CMSG(cmsg)) *fd = -1; else memcpy(fd, CMSG_DATA(cmsg), sizeof(*fd));