diff options
| author | Dmitry Chagin <dchagin@FreeBSD.org> | 2009-05-18 04:07:46 +0000 |
|---|---|---|
| committer | Dmitry Chagin <dchagin@FreeBSD.org> | 2009-05-18 04:07:46 +0000 |
| commit | 3a72bf04c4bf5ac46ccfd8868087947205bf2dbe (patch) | |
| tree | d322b4f678abeafc93996ff4856d9f8962760a22 /sys/compat/linux/linux_socket.c | |
| parent | 511e8a53439540af2e6e8b0e9860e2e1c8496d96 (diff) | |
Notes
Diffstat (limited to 'sys/compat/linux/linux_socket.c')
| -rw-r--r-- | sys/compat/linux/linux_socket.c | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/sys/compat/linux/linux_socket.c b/sys/compat/linux/linux_socket.c index 86cbcd64a65a..114a6d5e7de9 100644 --- a/sys/compat/linux/linux_socket.c +++ b/sys/compat/linux/linux_socket.c @@ -1148,7 +1148,7 @@ linux_recvmsg(struct thread *td, struct linux_recvmsg_args *args) struct mbuf **controlp; caddr_t outbuf; void *data; - int error; + int error, i, fd, fds, *fdp; error = copyin(PTRIN(args->msg), &linux_msg, sizeof(linux_msg)); if (error) @@ -1217,15 +1217,30 @@ linux_recvmsg(struct thread *td, struct linux_recvmsg_args *args) data = CMSG_DATA(cm); datalen = (caddr_t)cm + cm->cmsg_len - (caddr_t)data; - if (outlen + LINUX_CMSG_LEN(datalen) > - linux_msg.msg_controllen) { - if (outlen == 0) { - error = EMSGSIZE; - goto bad; - } else { - linux_msg.msg_flags |= LINUX_MSG_CTRUNC; - goto out; + switch (linux_cmsg->cmsg_type) + { + case LINUX_SCM_RIGHTS: + if (outlen + LINUX_CMSG_LEN(datalen) > + linux_msg.msg_controllen) { + if (outlen == 0) { + error = EMSGSIZE; + goto bad; + } else { + linux_msg.msg_flags |= + LINUX_MSG_CTRUNC; + goto out; + } + } + if (args->flags & LINUX_MSG_CMSG_CLOEXEC) { + fds = datalen / sizeof(int); + fdp = data; + for (i = 0; i < fds; i++) { + fd = *fdp++; + (void)kern_fcntl(td, fd, + F_SETFD, FD_CLOEXEC); + } } + break; } linux_cmsg->cmsg_len = LINUX_CMSG_LEN(datalen); |
