summaryrefslogtreecommitdiff
path: root/lib/passfd.c
diff options
context:
space:
mode:
authorEric Blake <eblake@redhat.com>2011-03-30 14:46:02 -0600
committerEric Blake <eblake@redhat.com>2011-03-30 17:48:24 -0600
commitf607f2cd9dfb5f1d0d48c1ec14fff9677065efbf (patch)
treea7022491d6d03ec51b1cbbccd5c18e5f29cf0bb0 /lib/passfd.c
parentb40633e65d8d154fcc30b356837c98908b63701c (diff)
downloadgnulib-f607f2cd9dfb5f1d0d48c1ec14fff9677065efbf.tar.gz
passfd: fix incorrect sendmsg arguments
The unit test hung on NetBSD, which pointed out a couple of bugs. * lib/passfd.c (sendfd): Avoid uninitialized msg_flags field, and incorrect msg_controllen value. * modules/passfd-tests (Depends-on): Check for alarm. * tests/test-passfd.c (main) [HAVE_DECL_ALARM]: Avoid hanging test. Reported by Bastien ROUCARIES. Signed-off-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'lib/passfd.c')
-rw-r--r--lib/passfd.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/passfd.c b/lib/passfd.c
index 573b80e450..5bf400d3e0 100644
--- a/lib/passfd.c
+++ b/lib/passfd.c
@@ -47,6 +47,7 @@ sendfd (int sock, int fd)
struct msghdr msg;
/* send at least one char */
+ memset (&msg, 0, sizeof msg);
iov[0].iov_base = &send;
iov[0].iov_len = 1;
msg.msg_iov = iov;
@@ -67,7 +68,6 @@ sendfd (int sock, int fd)
cmsg->cmsg_len = CMSG_LEN (sizeof (int));
/* Initialize the payload: */
memcpy (CMSG_DATA (cmsg), &fd, sizeof (fd));
- msg.msg_controllen = cmsg->cmsg_len;
#elif HAVE_UNIXSOCKET_SCM_RIGHTS_BSD43_WAY
msg.msg_accrights = &fd;
msg.msg_accrightslen = sizeof (fd);