Index: usr.sbin/nscd/nscdcli.c =================================================================== --- usr.sbin/nscd/nscdcli.c +++ usr.sbin/nscd/nscdcli.c @@ -138,14 +138,14 @@ struct msghdr cred_hdr; struct iovec iov; - struct { + union { struct cmsghdr hdr; - struct cmsgcred creds; + char cred[CMSG_SPACE(sizeof(struct cmsgcred))]; } cmsg; TRACE_IN(send_credentials); memset(&cmsg, 0, sizeof(cmsg)); - cmsg.hdr.cmsg_len = sizeof(cmsg); + cmsg.hdr.cmsg_len = CMSG_LEN(sizeof(cmsg)); cmsg.hdr.cmsg_level = SOL_SOCKET; cmsg.hdr.cmsg_type = SCM_CREDS; @@ -153,7 +153,7 @@ cred_hdr.msg_iov = &iov; cred_hdr.msg_iovlen = 1; cred_hdr.msg_control = &cmsg; - cred_hdr.msg_controllen = sizeof(cmsg); + cred_hdr.msg_controllen = CMSG_SPACE(sizeof(cmsg)); iov.iov_base = &type; iov.iov_len = sizeof(int); Index: usr.sbin/nscd/query.c =================================================================== --- usr.sbin/nscd/query.c +++ usr.sbin/nscd/query.c @@ -160,7 +160,7 @@ struct cmsgcred *cred; int elem_type; - struct { + union { struct cmsghdr hdr; char cred[CMSG_SPACE(sizeof(struct cmsgcred))]; } cmsg; @@ -171,8 +171,8 @@ memset(&cred_hdr, 0, sizeof(struct msghdr)); cred_hdr.msg_iov = &iov; cred_hdr.msg_iovlen = 1; - cred_hdr.msg_control = (caddr_t)&cmsg; - cred_hdr.msg_controllen = CMSG_LEN(sizeof(struct cmsgcred)); + cred_hdr.msg_control = &cmsg; + cred_hdr.msg_controllen = CMSG_SPACE(sizeof(cmsg)); memset(&iov, 0, sizeof(struct iovec)); iov.iov_base = &elem_type; @@ -183,7 +183,8 @@ return (-1); } - if (cmsg.hdr.cmsg_len < CMSG_LEN(sizeof(struct cmsgcred)) + if (cred_hdr.msg_controllen < CMSG_LEN(sizeof(struct cmsgcred)) + || cmsg.hdr.cmsg_len < CMSG_LEN(sizeof(struct cmsgcred)) || cmsg.hdr.cmsg_level != SOL_SOCKET || cmsg.hdr.cmsg_type != SCM_CREDS) { TRACE_OUT(on_query_startup);