From 23bf40059974a2d77a2d66e8f72721f7129a81ea Mon Sep 17 00:00:00 2001 From: rinor Date: Wed, 25 Sep 2024 15:40:56 +0000 Subject: [PATCH] fix: correct socket state checks and handle listen errors in netsyscall.c --- src/net/netsyscall.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/net/netsyscall.c b/src/net/netsyscall.c index 83dc56904..4f31f9a3b 100755 --- a/src/net/netsyscall.c +++ b/src/net/netsyscall.c @@ -2088,7 +2088,12 @@ static sysreturn netsock_listen(struct sock *sock, int backlog) } goto unlock_out; } - struct tcp_pcb * lw = tcp_listen_with_backlog(s->info.tcp.lw, backlog); + err_t err; + struct tcp_pcb * lw = tcp_listen_with_backlog_and_err(s->info.tcp.lw, backlog, &err); + if (!lw) { + rv = lwip_to_errno(err); + goto unlock_out; + } tcp_unref(s->info.tcp.lw); tcp_ref(lw); s->info.tcp.lw = lw;