From 44a87ce9b92bb756504a91bab3f4fef496a80ea0 Mon Sep 17 00:00:00 2001 From: tmm Date: Fri, 17 Jan 2003 19:20:00 +0000 Subject: Disallow listen() on sockets which are in the SS_ISCONNECTED or SS_ISCONNECTING state, returning EINVAL (which is what POSIX mandates in this case). listen() on connected or connecting sockets would cause them to enter a bad state; in the TCP case, this could cause sockets to go catatonic or panics, depending on how the socket was connected. Reviewed by: -net MFC after: 2 weeks --- sys/kern/uipc_socket.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index c4d596f..4163f2e 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -266,6 +266,10 @@ solisten(so, backlog, td) int s, error; s = splnet(); + if (so->so_state & (SS_ISCONNECTED | SS_ISCONNECTING)) { + splx(s); + return (EINVAL); + } error = (*so->so_proto->pr_usrreqs->pru_listen)(so, td); if (error) { splx(s); -- cgit v1.1