Index: lib/libc/sys/recv.2 =================================================================== --- lib/libc/sys/recv.2 +++ lib/libc/sys/recv.2 @@ -332,7 +332,7 @@ The argument .Fa s does not refer to a socket. -.It Bq Er EMSGSIZE +.It Bq Er EMFILE The .Fn recvmsg system call @@ -340,9 +340,18 @@ connection. However, the receiving program did not have enough free file descriptor slots to accept them. -In this case the descriptors are -closed, any pending data can be returned by another call to +In this case the descriptors are closed, with pending data either discarded +in case of unreliable datagram protocol or preserved in case of a reliable +protocol. +The pending data can be returned by another call to .Fn recvmsg . +.It Bq Er EMSGSIZE +The +.Fa msg_iovlen +member of the +.Fa msghdr +structure pointed to by message is less than or equal to 0, or is greater than +.Va IOV_MAX . .It Bq Er EAGAIN The socket is marked non-blocking and the receive operation would block, or Index: sys/kern/uipc_usrreq.c =================================================================== --- sys/kern/uipc_usrreq.c +++ sys/kern/uipc_usrreq.c @@ -2547,9 +2547,8 @@ fdp = (int *) CMSG_DATA(mtod(*controlp, struct cmsghdr *)); - if (fdallocn(td, 0, fdp, newfds) != 0) { + if ((error = fdallocn(td, 0, fdp, newfds))) { FILEDESC_XUNLOCK(fdesc); - error = EMSGSIZE; unp_freerights(fdep, newfds); m_freem(*controlp); *controlp = NULL; Index: tests/sys/kern/unix_passfd_test.c =================================================================== --- tests/sys/kern/unix_passfd_test.c +++ tests/sys/kern/unix_passfd_test.c @@ -428,8 +428,8 @@ msghdr.msg_controllen = CMSG_LEN(sizeof(int)); ATF_REQUIRE(sendmsg(fd[0], &msghdr, 0) == 1); ATF_REQUIRE(recvmsg(fd[1], &msghdr, 0) == -1); - /* Such attempt shall fail with EMSGSIZE. */ - ATF_REQUIRE(errno == EMSGSIZE); + /* Such attempt shall fail with EMFILE. */ + ATF_REQUIRE(errno == EMFILE); ATF_REQUIRE(getnfds() == nfds); #if TEST_PROTO == SOCK_STREAM /*