diff options
| author | Jesse Noller <jnoller@gmail.com> | 2009-01-19 15:12:22 (GMT) |
|---|---|---|
| committer | Jesse Noller <jnoller@gmail.com> | 2009-01-19 15:12:22 (GMT) |
| commit | 9a5b2ad38d605206f05a52fe32868d3f839e8a86 (patch) | |
| tree | 8dd72269c71a0e279ebc7b3d71f879ab89dd05c5 /Modules/_multiprocessing/socket_connection.c | |
| parent | 273c1d9a8ba2d7dbd03afec7e7d6aadcb884e758 (diff) | |
| download | cpython-9a5b2ad38d605206f05a52fe32868d3f839e8a86.zip cpython-9a5b2ad38d605206f05a52fe32868d3f839e8a86.tar.gz cpython-9a5b2ad38d605206f05a52fe32868d3f839e8a86.tar.bz2 | |
Resolve issue 3321: (segfault) _multiprocessing.Connection() doesn't check handle
Diffstat (limited to 'Modules/_multiprocessing/socket_connection.c')
| -rw-r--r-- | Modules/_multiprocessing/socket_connection.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/Modules/_multiprocessing/socket_connection.c b/Modules/_multiprocessing/socket_connection.c index e5d2d15..ad4005b 100644 --- a/Modules/_multiprocessing/socket_connection.c +++ b/Modules/_multiprocessing/socket_connection.c @@ -153,11 +153,23 @@ conn_recv_string(ConnectionObject *conn, char *buffer, */ static int -conn_poll(ConnectionObject *conn, double timeout) +conn_poll(ConnectionObject *conn, double timeout, PyThreadState *_save) { int res; fd_set rfds; + /* + * Verify the handle, issue 3321. Not required for windows. + */ + #ifndef MS_WINDOWS + if (((int)conn->handle) < 0 || ((int)conn->handle) >= FD_SETSIZE) { + Py_BLOCK_THREADS + PyErr_SetString(PyExc_IOError, "handle out of range in select()"); + Py_UNBLOCK_THREADS + return MP_EXCEPTION_HAS_BEEN_SET; + } + #endif + FD_ZERO(&rfds); FD_SET((SOCKET)conn->handle, &rfds); |
