summaryrefslogtreecommitdiffstats
path: root/Modules/socketmodule.c
diff options
context:
space:
mode:
authorRonald Oussoren <ronaldoussoren@mac.com>2013-05-24 11:51:21 (GMT)
committerRonald Oussoren <ronaldoussoren@mac.com>2013-05-24 11:51:21 (GMT)
commitdc3e6cc452a2a4409a4d12804fab4e474abbf9ff (patch)
treed569856625cff5f0a4b80e70a2e33c3db9cf4180 /Modules/socketmodule.c
parentcbc77bbbc0d0cbdb50889f556b9a514870481314 (diff)
parent27a4ac535f112b87d91f433eb9edcd0ae9988354 (diff)
downloadcpython-dc3e6cc452a2a4409a4d12804fab4e474abbf9ff.zip
cpython-dc3e6cc452a2a4409a4d12804fab4e474abbf9ff.tar.gz
cpython-dc3e6cc452a2a4409a4d12804fab4e474abbf9ff.tar.bz2
(3.3->default) Issue #17269: Workaround for a platform bug in getaddrinfo on OSX
Without this patch socket.getaddrinfo crashed when called with some unusual argument combinations.
Diffstat (limited to 'Modules/socketmodule.c')
-rw-r--r--Modules/socketmodule.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index fa75a10..846d659 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -4978,6 +4978,15 @@ socket_getaddrinfo(PyObject *self, PyObject *args, PyObject* kwargs)
PyErr_SetString(PyExc_OSError, "Int or String expected");
goto err;
}
+#ifdef __APPLE__
+ if ((flags & AI_NUMERICSERV) && (pptr == NULL || (pptr[0] == '0' && pptr[1] == 0))) {
+ /* On OSX upto at least OSX 10.8 getaddrinfo crashes
+ * if AI_NUMERICSERV is set and the servname is NULL or "0".
+ * This workaround avoids a segfault in libsystem.
+ */
+ pptr = "00";
+ }
+#endif
memset(&hints, 0, sizeof(hints));
hints.ai_family = family;
hints.ai_socktype = socktype;