From 6f7cab9301e69525a3b7babe3e1982988665829a Mon Sep 17 00:00:00 2001 From: Thomas Moestl Date: Fri, 17 Jan 2003 19:20:00 +0000 Subject: [PATCH] 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 c4d596fd0821..4163f2e1d495 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);