diff --git a/CHANGELOG b/CHANGELOG index 54127d4a..cc584596 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -26,6 +26,9 @@ HISTORY ++ Bugfixes: + 2017-02-24: Simon Goldschmidt + * sockets.c: fixed that select ignored invalid/not open sockets in the fd_sets (bug #50392) + 2017-02-16: Simon Goldschmidt * LWIP_NETCONN_FULLDUPLEX: fixed shutdown during write (bug #50274) diff --git a/src/api/sockets.c b/src/api/sockets.c index 8e33b416..690f5a62 100644 --- a/src/api/sockets.c +++ b/src/api/sockets.c @@ -1347,7 +1347,8 @@ lwip_selscan(int maxfdp1, fd_set *readset_in, fd_set *writeset_in, fd_set *excep } } else { SYS_ARCH_UNPROTECT(lev); - /* continue on to next FD in list */ + /* no a valid open socket */ + return -1; } } /* copy local sets to the ones provided as arguments */ @@ -1384,6 +1385,11 @@ lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset, currently match */ nready = lwip_selscan(maxfdp1, readset, writeset, exceptset, &lreadset, &lwriteset, &lexceptset); + if (nready < 0) { + set_errno(EBADF); + return -1; + } + /* If we don't have any current events, then suspend if we are supposed to */ if (!nready) { if (timeout && timeout->tv_sec == 0 && timeout->tv_usec == 0) {