summaryrefslogtreecommitdiff
path: root/libexec
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2004-08-30 18:14:34 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2004-08-30 18:14:34 +0000
commita50ea864e13261b030a966155cd54a19bc844789 (patch)
tree6f3f46e36625f1a8c07154710f084579566c7196 /libexec
parentccc4a76c57abbfcf253bf6be25ea72c42fd0186d (diff)
Use CMSG_SPACE when allocating space for the control message.
Fixes fd passing problems on sparc and sparc64. OK henning@
Diffstat (limited to 'libexec')
-rw-r--r--libexec/login_skey/login_skey.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/libexec/login_skey/login_skey.c b/libexec/login_skey/login_skey.c
index baa23a6fb35..948c806c228 100644
--- a/libexec/login_skey/login_skey.c
+++ b/libexec/login_skey/login_skey.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: login_skey.c,v 1.15 2004/08/11 17:09:25 millert Exp $ */
+/* $OpenBSD: login_skey.c,v 1.16 2004/08/30 18:14:33 millert Exp $ */
/*
* Copyright (c) 2000, 2001, 2004 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -261,18 +261,18 @@ send_fd(int sock)
{
struct msghdr msg;
struct cmsghdr *cmp;
- char cmsgbuf[CMSG_LEN(sizeof(int))];
+ char cmsgbuf[CMSG_SPACE(sizeof(int))];
memset(&msg, 0, sizeof(msg));
msg.msg_control = cmsgbuf;
- msg.msg_controllen = sizeof(cmsgbuf);
+ msg.msg_controllen = CMSG_LEN(sizeof(int));
- cmp = (struct cmsghdr *)cmsgbuf;
- cmp->cmsg_len = sizeof(cmsgbuf);
+ cmp = CMSG_FIRSTHDR(&msg);
+ cmp->cmsg_len = CMSG_LEN(sizeof(int));
cmp->cmsg_level = SOL_SOCKET;
cmp->cmsg_type = SCM_RIGHTS;
- *(int *)CMSG_DATA(cmsgbuf) = fileno(skey.keyfile);
+ *(int *)CMSG_DATA(cmp) = fileno(skey.keyfile);
if (sendmsg(sock, &msg, 0) < 0)
syslog(LOG_ERR, "sendmsg: %m");