diff options
author | Ronald Oussoren <ronaldoussoren@mac.com> | 2013-05-24 11:45:27 (GMT) |
---|---|---|
committer | Ronald Oussoren <ronaldoussoren@mac.com> | 2013-05-24 11:45:27 (GMT) |
commit | 16c52a337644e0223c2004168551ff2ba7884cb7 (patch) | |
tree | 89fd45f481e110acf8cf77308f7256b816c86b48 /Modules/socketmodule.c | |
parent | 668b0058a381b1e44e3d053cc949fb1875d7f107 (diff) | |
download | cpython-16c52a337644e0223c2004168551ff2ba7884cb7.zip cpython-16c52a337644e0223c2004168551ff2ba7884cb7.tar.gz cpython-16c52a337644e0223c2004168551ff2ba7884cb7.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 bdc055d..238c849 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -4179,6 +4179,15 @@ socket_getaddrinfo(PyObject *self, PyObject *args) "getaddrinfo() argument 2 must be integer or string"); 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; |