diff Modules/socketmodule.c @ 72115:852ca32eb18d 3.2

Issue #12287: Fix a stack corruption in ossaudiodev module when the FD is greater than FD_SETSIZE.
author Charles-François Natali <neologix@free.fr>
date Sun, 28 Aug 2011 17:51:43 +0200
parents ab3432a81c26
children cc346a672091 ad1c09b6a5b9
line wrap: on
line diff
--- a/Modules/socketmodule.c	Sun Aug 28 11:26:46 2011 +0200
+++ b/Modules/socketmodule.c	Sun Aug 28 17:51:43 2011 +0200
@@ -455,18 +455,14 @@
 #include <sys/poll.h>
 #endif
 
-#ifdef Py_SOCKET_FD_CAN_BE_GE_FD_SETSIZE
-/* Platform can select file descriptors beyond FD_SETSIZE */
-#define IS_SELECTABLE(s) 1
-#elif defined(HAVE_POLL)
+#ifdef HAVE_POLL
 /* Instead of select(), we'll use poll() since poll() works on any fd. */
 #define IS_SELECTABLE(s) 1
 /* Can we call select() with this socket without a buffer overrun? */
 #else
-/* POSIX says selecting file descriptors beyond FD_SETSIZE
-   has undefined behaviour.  If there's no timeout left, we don't have to
-   call select, so it's a safe, little white lie. */
-#define IS_SELECTABLE(s) ((s)->sock_fd < FD_SETSIZE || s->sock_timeout <= 0.0)
+/* If there's no timeout left, we don't have to call select, so it's a safe,
+ * little white lie. */
+#define IS_SELECTABLE(s) (_PyIsSelectable_fd((s)->sock_fd) || (s)->sock_timeout <= 0.0)
 #endif
 
 static PyObject*