lib: Use msghdr_prep_recv_fds in unix_msg
authorVolker Lendecke <vl@samba.org>
Wed, 31 Dec 2014 13:19:13 +0000 (14:19 +0100)
committerJeremy Allison <jra@samba.org>
Mon, 5 Jan 2015 23:33:10 +0000 (00:33 +0100)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/lib/unix_msg/unix_msg.c

index c5f8143e0feab72390d1fdba52f782ed6f7e3163..51bb0c6fbc94702839a625c3d13961aab5362d1b 100644 (file)
@@ -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