From 4486c20089e3e557409ab41467c176da26f1564a Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Fri, 10 Jul 2009 00:27:01 +0200 Subject: [PATCH] Fix fd passing on FreeBSD/amd64 and possibly Solaris/sparc. The number of file descriptors in the message was not determined correctly. --- libratbox/src/commio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libratbox/src/commio.c b/libratbox/src/commio.c index 7318cab..cd1f5a0 100644 --- a/libratbox/src/commio.c +++ b/libratbox/src/commio.c @@ -2156,7 +2156,7 @@ rb_recv_fd_buf(rb_fde_t *F, void *data, size_t datasize, rb_fde_t **xF, int nfds if(msg.msg_controllen > 0 && msg.msg_control != NULL && (cmsg = CMSG_FIRSTHDR(&msg)) != NULL) { - rfds = (msg.msg_controllen - sizeof(struct cmsghdr)) / sizeof(int); + rfds = ((unsigned char *)cmsg + cmsg->cmsg_len - CMSG_DATA(cmsg)) / sizeof(int); for(x = 0; x < nfds && x < rfds; x++) {