]> jfr.im git - irc/rqf/shadowircd.git/commitdiff
Fix fd passing on FreeBSD/amd64 and possibly Solaris/sparc.
authorJilles Tjoelker <redacted>
Thu, 9 Jul 2009 22:27:01 +0000 (00:27 +0200)
committerJilles Tjoelker <redacted>
Thu, 9 Jul 2009 22:27:01 +0000 (00:27 +0200)
The number of file descriptors in the message was not
determined correctly.

libratbox/src/commio.c

index 7318cabee90cc7a9cf77f91e7eabd61694f4eb26..cd1f5a07fce4c5f4a7daf5ebbb2ee5e186049c89 100644 (file)
@@ -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++)
                {