[dovecot-cvs] dovecot/src/lib fdpass.c,1.8,1.9

cras at procontrol.fi cras at procontrol.fi
Sat Dec 28 21:20:39 EET 2002


Update of /home/cvs/dovecot/src/lib
In directory danu:/tmp/cvs-serv28004

Modified Files:
	fdpass.c 
Log Message:
Fixed to work with 64bit BSD systems.



Index: fdpass.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib/fdpass.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- fdpass.c	16 Nov 2002 05:19:03 -0000	1.8
+++ fdpass.c	28 Dec 2002 19:20:37 -0000	1.9
@@ -48,27 +48,27 @@
         struct cmsghdr *cmsg;
 	char buf[CMSG_SPACE(sizeof(int))];
 
-	i_assert(size < SSIZE_T_MAX);
+	i_assert(size > 0 && size < SSIZE_T_MAX);
 
 	memset(&msg, 0, sizeof (struct msghdr));
 
         iov.iov_base = (void *) data;
         iov.iov_len = size;
 
-	if (send_fd != -1) {
-		msg.msg_control = buf;
-		msg.msg_controllen = sizeof(buf);
-	}
-
         msg.msg_iov = &iov;
 	msg.msg_iovlen = 1;
 
 	if (send_fd != -1) {
+		msg.msg_control = buf;
+		msg.msg_controllen = sizeof(buf);
+
 		cmsg = CMSG_FIRSTHDR(&msg);
 		cmsg->cmsg_level = SOL_SOCKET;
 		cmsg->cmsg_type = SCM_RIGHTS;
 		cmsg->cmsg_len = CMSG_LEN(sizeof(int));
 		*((int *) CMSG_DATA(cmsg)) = send_fd;
+
+		msg.msg_controllen = cmsg->cmsg_len;
 	}
 
 	return sendmsg(handle, &msg, 0);
@@ -82,7 +82,7 @@
 	ssize_t ret;
 	char buf[CMSG_SPACE(sizeof(int))];
 
-	i_assert(size < SSIZE_T_MAX);
+	i_assert(size > 0 && size < SSIZE_T_MAX);
 
 	memset(&msg, 0, sizeof (struct msghdr));
 




More information about the dovecot-cvs mailing list