diff options
author | Ronald Oussoren <ronaldoussoren@mac.com> | 2013-05-24 11:47:37 (GMT) |
---|---|---|
committer | Ronald Oussoren <ronaldoussoren@mac.com> | 2013-05-24 11:47:37 (GMT) |
commit | 27a4ac535f112b87d91f433eb9edcd0ae9988354 (patch) | |
tree | 6a2ae9b31323e7134f237af7e2209bc880d74fec /Modules/socketmodule.c | |
parent | 05ec6aca3a73772f16128628e8c3786b3e0cc4e6 (diff) | |
download | cpython-27a4ac535f112b87d91f433eb9edcd0ae9988354.zip cpython-27a4ac535f112b87d91f433eb9edcd0ae9988354.tar.gz cpython-27a4ac535f112b87d91f433eb9edcd0ae9988354.tar.bz2 |
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.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index 9200002..679143c 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -5041,6 +5041,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; |