| 910 | } |
| 911 | |
| 912 | int |
| 913 | kern_recvit(struct thread *td, int s, struct msghdr *mp, enum uio_seg fromseg, |
| 914 | struct mbuf **controlp) |
| 915 | { |
| 916 | struct uio auio; |
| 917 | struct iovec *iov; |
| 918 | struct mbuf *control, *m; |
| 919 | caddr_t ctlbuf; |
| 920 | struct file *fp; |
| 921 | struct socket *so; |
| 922 | struct sockaddr *fromsa = NULL; |
| 923 | #ifdef KTRACE |
| 924 | struct uio *ktruio = NULL; |
| 925 | #endif |
| 926 | ssize_t len; |
| 927 | int error, i; |
| 928 | |
| 929 | if (controlp != NULL) |
| 930 | *controlp = NULL; |
| 931 | |
| 932 | AUDIT_ARG_FD(s); |
| 933 | error = getsock_cap(td, s, &cap_recv_rights, |
| 934 | &fp, NULL, NULL); |
| 935 | if (error != 0) |
| 936 | return (error); |
| 937 | so = fp->f_data; |
| 938 | |
| 939 | #ifdef MAC |
| 940 | error = mac_socket_check_receive(td->td_ucred, so); |
| 941 | if (error != 0) { |
| 942 | fdrop(fp, td); |
| 943 | return (error); |
| 944 | } |
| 945 | #endif |
| 946 | |
| 947 | auio.uio_iov = mp->msg_iov; |
| 948 | auio.uio_iovcnt = mp->msg_iovlen; |
| 949 | auio.uio_segflg = UIO_USERSPACE; |
| 950 | auio.uio_rw = UIO_READ; |
| 951 | auio.uio_td = td; |
| 952 | auio.uio_offset = 0; /* XXX */ |
| 953 | auio.uio_resid = 0; |
| 954 | iov = mp->msg_iov; |
| 955 | for (i = 0; i < mp->msg_iovlen; i++, iov++) { |
| 956 | if ((auio.uio_resid += iov->iov_len) < 0) { |
| 957 | fdrop(fp, td); |
| 958 | return (EINVAL); |
| 959 | } |
| 960 | } |
| 961 | #ifdef KTRACE |
| 962 | if (KTRPOINT(td, KTR_GENIO)) |
| 963 | ktruio = cloneuio(&auio); |
| 964 | #endif |
| 965 | control = NULL; |
| 966 | len = auio.uio_resid; |
| 967 | error = soreceive(so, &fromsa, &auio, NULL, |
| 968 | (mp->msg_control || controlp) ? &control : NULL, |
| 969 | &mp->msg_flags); |
no test coverage detected