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>
+2011-03-30 Eric Blake <eblake@redhat.com>
+
+ passfd: fix incorrect sendmsg arguments
+ * 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.
+
2011-03-30 Bruno Haible <bruno@clisp.org>
c-strcasestr: Relicense under LGPLv2+.
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;
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);
Depends-on:
configure.ac:
+AC_CHECK_DECLS_ONCE([alarm])
Makefile.am:
TESTS += test-passfd
#include "passfd.h"
#include <fcntl.h>
+#include <signal.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
int fd;
struct stat st;
+#if HAVE_DECL_ALARM
+ /* Avoid hanging on failure. */
+ signal (SIGALRM, SIG_DFL);
+ alarm (5);
+#endif
+
fdnull = open ("/dev/null", O_RDWR);
if (fdnull < 0)
{