mirror of
https://github.com/python/cpython.git
synced 2025-10-17 20:28:43 +00:00
Issue #17269: Workaround for a platform bug in getaddrinfo on OSX
Without this patch socket.getaddrinfo crashed when called with some unusual argument combinations.
This commit is contained in:
parent
05ec6aca3a
commit
27a4ac535f
3 changed files with 15 additions and 0 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue