From 8caa866b08172dd5da5ef2cfadad4210c1dabf08 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 31 Dec 2014 14:19:13 +0100 Subject: lib: Use msghdr_prep_recv_fds in unix_msg Signed-off-by: Volker Lendecke Reviewed-by: Ralph Boehme --- source3/lib/unix_msg/unix_msg.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/unix_msg/unix_msg.c b/source3/lib/unix_msg/unix_msg.c index c5f8143e0f..51bb0c6fbc 100644 --- a/source3/lib/unix_msg/unix_msg.c +++ b/source3/lib/unix_msg/unix_msg.c @@ -272,9 +272,8 @@ static void unix_dgram_recv_handler(struct poll_watch *w, int fd, short events, int flags = 0; struct msghdr msg; struct iovec iov; -#ifdef HAVE_STRUCT_MSGHDR_MSG_CONTROL - char buf[CMSG_SPACE(sizeof(int)*INT8_MAX)] = { 0, }; -#endif /* HAVE_STRUCT_MSGHDR_MSG_CONTROL */ + size_t bufsize = msghdr_prep_recv_fds(NULL, NULL, 0, INT8_MAX); + uint8_t buf[bufsize]; iov = (struct iovec) { .iov_base = (void *)ctx->recv_buf, @@ -284,12 +283,10 @@ static void unix_dgram_recv_handler(struct poll_watch *w, int fd, short events, msg = (struct msghdr) { .msg_iov = &iov, .msg_iovlen = 1, -#ifdef HAVE_STRUCT_MSGHDR_MSG_CONTROL - .msg_control = buf, - .msg_controllen = sizeof(buf), -#endif }; + msghdr_prep_recv_fds(&msg, buf, bufsize, INT8_MAX); + #ifdef MSG_CMSG_CLOEXEC flags |= MSG_CMSG_CLOEXEC; #endif -- cgit