[socket] Fix bad parameter passed to select (#4390)
[mono.git] / mono / utils / mono-poll.c
index 5e5adfe2f0009e64f32907f1750abc671ce1376a..d81b4eb9168f050626d4afd5ab31628fd5d061fa 100755 (executable)
@@ -1,3 +1,10 @@
+#include <config.h>
+
+#ifdef HOST_WIN32
+/* For select */
+#include <winsock2.h>
+#endif
+
 #include "mono-poll.h"
 #include <errno.h>
 
@@ -20,11 +27,6 @@ mono_poll (mono_pollfd *ufds, unsigned int nfds, int timeout)
 }
 #else
 
-#ifdef HOST_WIN32
-/* For select */
-#include <winsock2.h>
-#endif
-
 int
 mono_poll (mono_pollfd *ufds, unsigned int nfds, int timeout)
 {
@@ -58,7 +60,7 @@ mono_poll (mono_pollfd *ufds, unsigned int nfds, int timeout)
                        return 1;
                }
 #else
-               if (fd > FD_SETSIZE) {
+               if (fd >= FD_SETSIZE) {
                        ufds [i].revents = MONO_POLLNVAL;
                        return 1;
                }