From 23be20872761de1f0c673b875ee43ac60ed76d37 Mon Sep 17 00:00:00 2001 From: June McEnroe Date: Sun, 29 Jul 2018 20:56:12 -0400 Subject: Fix dtch cmsg size Apparently you actually need CMSG_SPACE and not just CMSG_LEN... Well done, everyone. --- bin/dtch.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'bin') diff --git a/bin/dtch.c b/bin/dtch.c index a0cd2899..6466c3be 100644 --- a/bin/dtch.c +++ b/bin/dtch.c @@ -56,7 +56,7 @@ static char z; static struct iovec iov = { .iov_base = &z, .iov_len = 1 }; static ssize_t sendFd(int sock, int fd) { - size_t size = CMSG_LEN(sizeof(int)); + size_t size = CMSG_SPACE(sizeof(int)); char buf[size]; struct msghdr msg = { .msg_iov = &iov, @@ -66,7 +66,7 @@ static ssize_t sendFd(int sock, int fd) { }; struct cmsghdr *cmsg = CMSG_FIRSTHDR(&msg); - cmsg->cmsg_len = size; + cmsg->cmsg_len = CMSG_LEN(sizeof(int)); cmsg->cmsg_level = SOL_SOCKET; cmsg->cmsg_type = SCM_RIGHTS; *(int *)CMSG_DATA(cmsg) = fd; @@ -75,7 +75,7 @@ static ssize_t sendFd(int sock, int fd) { } static int recvFd(int sock) { - size_t size = CMSG_LEN(sizeof(int)); + size_t size = CMSG_SPACE(sizeof(int)); char buf[size]; struct msghdr msg = { .msg_iov = &iov, -- cgit 1.4.1