summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Noller <jnoller@gmail.com>2009-03-30 16:11:16 (GMT)
committerJesse Noller <jnoller@gmail.com>2009-03-30 16:11:16 (GMT)
commite6bab480acb17ba62d948f22a29cdd08289e7986 (patch)
treebf5ce0dccc380506d18d30b989172987f192fd86
parent783fa44f2cba927dd7c1e2b03866a01a5dd82990 (diff)
downloadcpython-e6bab480acb17ba62d948f22a29cdd08289e7986.zip
cpython-e6bab480acb17ba62d948f22a29cdd08289e7986.tar.gz
cpython-e6bab480acb17ba62d948f22a29cdd08289e7986.tar.bz2
Merge 68768 to maint
-rw-r--r--Lib/test/test_multiprocessing.py16
-rw-r--r--Misc/NEWS7
-rw-r--r--Modules/_multiprocessing/connection.h2
-rw-r--r--Modules/_multiprocessing/socket_connection.c14
4 files changed, 36 insertions, 3 deletions
diff --git a/Lib/test/test_multiprocessing.py b/Lib/test/test_multiprocessing.py
index 2daff7e..d4ce4fa 100644
--- a/Lib/test/test_multiprocessing.py
+++ b/Lib/test/test_multiprocessing.py
@@ -61,6 +61,8 @@ else:
HAVE_GETVALUE = not getattr(_multiprocessing,
'HAVE_BROKEN_SEM_GETVALUE', False)
+WIN32 = (sys.platform == "win32")
+
#
# Creates a wrapper for a function which records the time it takes to finish
#
@@ -1682,6 +1684,18 @@ class _TestLogging(BaseTestCase):
logger.setLevel(level=LOG_LEVEL)
#
+# Test to verify handle verification, see issue 3321
+#
+
+class TestInvalidHandle(unittest.TestCase):
+
+ def test_invalid_handles(self):
+ if WIN32:
+ return
+ conn = _multiprocessing.Connection(44977608)
+ self.assertRaises(IOError, conn.poll)
+ self.assertRaises(IOError, _multiprocessing.Connection, -1)
+#
# Functions used to create test cases from the base ones in this module
#
@@ -1785,7 +1799,7 @@ class OtherTest(unittest.TestCase):
multiprocessing.connection.answer_challenge,
_FakeConnection(), b'abc')
-testcases_other = [OtherTest]
+testcases_other = [OtherTest, TestInvalidHandle]
#
#
diff --git a/Misc/NEWS b/Misc/NEWS
index 40322d2..aca1cc5 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -150,6 +150,13 @@ Library
- Issue #5203: Fixed ctypes segfaults when passing a unicode string to a
function without argtypes (only occurs if HAVE_USABLE_WCHAR_T is false).
+- Issue #3321: _multiprocessing.Connection() doesn't check handle; added checks
+ for *nix machines for negative handles and large int handles. Without this check
+ it is possible to segfault the interpreter.
+
+- Issue #4449: AssertionError in mp_benchmarks.py, caused by an underlying issue
+ in sharedctypes.py.
+
- Issue #3386: distutils.sysconfig.get_python_lib prefix argument was ignored
under NT and OS2. Patch by Philip Jenvey.
diff --git a/Modules/_multiprocessing/connection.h b/Modules/_multiprocessing/connection.h
index 155b61b..458d1d3 100644
--- a/Modules/_multiprocessing/connection.h
+++ b/Modules/_multiprocessing/connection.h
@@ -354,7 +354,7 @@ connection_poll(ConnectionObject *self, PyObject *args)
}
Py_BEGIN_ALLOW_THREADS
- res = conn_poll(self, timeout);
+ res = conn_poll(self, timeout, _save);
Py_END_ALLOW_THREADS
switch (res) {
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);