+2006-11-09 Dick Porter <dick@ximian.com>
+
+ * sockets.c (_wapi_select): Do some sanity checking on the
+ fd_sets, to avoid file descriptors > FD_SETSIZE.
+ (_wapi_FD_CLR, _wapi_FD_ISSET, _wapi_FD_SET): Avoid file
+ descriptors > FD_SETSIZE.
+
2006-10-27 Dick Porter <dick@ximian.com>
* io.c (GetFileAttributes): Force symlinks to directories to be
int _wapi_select(int nfds G_GNUC_UNUSED, fd_set *readfds, fd_set *writefds,
fd_set *exceptfds, struct timeval *timeout)
{
- int ret;
+ int ret, maxfd;
if (startup_count == 0) {
WSASetLastError (WSANOTINITIALISED);
return(SOCKET_ERROR);
}
+ for (maxfd = FD_SETSIZE-1; maxfd >= 0; maxfd--) {
+ if ((readfds && FD_ISSET (maxfd, readfds)) ||
+ (writefds && FD_ISSET (maxfd, writefds)) ||
+ (exceptfds && FD_ISSET (maxfd, exceptfds))) {
+ break;
+ }
+ }
+
+ if (maxfd == -1) {
+ WSASetLastError (WSAEINVAL);
+ return(SOCKET_ERROR);
+ }
+
do {
- ret = select(getdtablesize (), readfds, writefds, exceptfds,
+ ret = select(maxfd + 1, readfds, writefds, exceptfds,
timeout);
} while (ret == -1 && errno == EINTR &&
!_wapi_thread_cur_apc_pending ());
{
gpointer handle = GUINT_TO_POINTER (fd);
+ if (fd >= FD_SETSIZE) {
+ WSASetLastError (WSAEINVAL);
+ return;
+ }
+
if (_wapi_handle_type (handle) != WAPI_HANDLE_SOCKET) {
WSASetLastError (WSAENOTSOCK);
return;
{
gpointer handle = GUINT_TO_POINTER (fd);
+ if (fd >= FD_SETSIZE) {
+ WSASetLastError (WSAEINVAL);
+ return(0);
+ }
+
if (_wapi_handle_type (handle) != WAPI_HANDLE_SOCKET) {
WSASetLastError (WSAENOTSOCK);
return(0);
{
gpointer handle = GUINT_TO_POINTER (fd);
+ if (fd >= FD_SETSIZE) {
+ WSASetLastError (WSAEINVAL);
+ return;
+ }
+
if (_wapi_handle_type (handle) != WAPI_HANDLE_SOCKET) {
WSASetLastError (WSAENOTSOCK);
return;