Index: libsolve/sockprot.cpp =================================================================== --- libsolve/sockprot.cpp (revision 197) +++ libsolve/sockprot.cpp (revision 198) @@ -229,14 +229,19 @@ if (nonblock) return fd; +#ifndef WIN32 + if (fd >= FD_SETSIZE) + { + close (fd); + errno = EMFILE; + } +#endif + /* Waits until connection is established */ fd_set s; FD_ZERO (&s); FD_SET (fd, &s); - int err = 0; - socklen_t len = sizeof (err); - if (select (fd + 1, NULL, &s, NULL, NULL) != 1) { SetError (); @@ -248,6 +253,9 @@ continue; } + int err = 0; + socklen_t len = sizeof (err); + if (getsockopt (fd, SOL_SOCKET, SO_ERROR, &err, &len)) { SetError (); Index: src/bridge.cpp =================================================================== --- src/bridge.cpp (revision 197) +++ src/bridge.cpp (revision 198) @@ -34,6 +34,7 @@ #ifdef HAVE_SYS_SOCKET_H # include // shutdown(), send(), recv() #endif +#include #include "log.h" @@ -115,6 +116,14 @@ long totalcount = 0; bridge b[2]; +#ifndef WIN32 + if ((fds[0] >= FD_SETSIZE) || (fds[1] >= FD_SETSIZE)) + { + errno = EINVAL; + return -1; + } +#endif + b[0].outfd = b[1].infd = fds[0]; b[0].infd = b[1].outfd = fds[1]; b[0].buflen = b[1].buflen = 0;