From 066a2b022d076ea921691a949e9f75bdb61c6812 Mon Sep 17 00:00:00 2001 From: yuanjm Date: Thu, 28 Jan 2021 21:00:37 +0100 Subject: [PATCH] lwip_selscan: lwip_selscan return -1 without setting errno number Signed-off-by: Simon Goldschmidt --- src/api/sockets.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/api/sockets.c b/src/api/sockets.c index 232a8343..78526350 100644 --- a/src/api/sockets.c +++ b/src/api/sockets.c @@ -2072,7 +2072,9 @@ lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset, /* Call lwip_selscan again: there could have been events between the last scan (without us on the list) and putting us on the list! */ nready = lwip_selscan(maxfdp1, readset, writeset, exceptset, &lreadset, &lwriteset, &lexceptset); - if (!nready) { + if (nready < 0) { + set_errno(EBADF); + } else if (!nready) { /* Still none ready, just wait to be woken */ if (timeout == 0) { /* Wait forever */ @@ -2146,6 +2148,11 @@ lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset, /* See what's set now after waiting */ nready = lwip_selscan(maxfdp1, readset, writeset, exceptset, &lreadset, &lwriteset, &lexceptset); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_select: nready=%d\n", nready)); + if (nready < 0) { + set_errno(EBADF); + lwip_select_dec_sockets_used(maxfdp1, &used_sockets); + return -1; + } } } }