diff options
author | ed <ed@FreeBSD.org> | 2015-07-10 06:47:14 +0000 |
---|---|---|
committer | ed <ed@FreeBSD.org> | 2015-07-10 06:47:14 +0000 |
commit | 790c476c1a960dc345d9eb1338ed3a9fad115586 (patch) | |
tree | 961d12c4241db9fc8ed403d4ea8f6fbea5c0fead | |
parent | c354cad8fde9b680d7f14a49789fbb1063153772 (diff) | |
download | FreeBSD-src-790c476c1a960dc345d9eb1338ed3a9fad115586.zip FreeBSD-src-790c476c1a960dc345d9eb1338ed3a9fad115586.tar.gz |
Let listen() return EDESTADDRREQ when not bound.
We currently return EINVAL when calling listen() on a UNIX socket that
has not been bound to a pathname. If my interpretation of POSIX is
correct, we should return EDESTADDRREQ: "The socket is not bound to a
local address, and the protocol does not support listening on an unbound
socket."
Return EDESTADDRREQ instead when not bound and not connected.
Differential Revision: https://reviews.freebsd.org/D3038
Reviewed by: gnn, network
-rw-r--r-- | sys/kern/uipc_usrreq.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c index acf9fe9..7b2984c 100644 --- a/sys/kern/uipc_usrreq.c +++ b/sys/kern/uipc_usrreq.c @@ -736,8 +736,10 @@ uipc_listen(struct socket *so, int backlog, struct thread *td) UNP_PCB_LOCK(unp); if (unp->unp_vnode == NULL) { + /* Already connected or not bound to an address. */ + error = unp->unp_conn != NULL ? EINVAL : EDESTADDRREQ; UNP_PCB_UNLOCK(unp); - return (EINVAL); + return (error); } SOCK_LOCK(so); |