Mercurial > cpython-lru_cache-weakref
diff Modules/socketmodule.c @ 83907:3c4a5dc29417 3.3
Issue #17269: Workaround for a platform bug in getaddrinfo on OSX
Without this patch socket.getaddrinfo crashed when called
with some unusual argument combinations.
| author | Ronald Oussoren <ronaldoussoren@mac.com> |
|---|---|
| date | Fri, 24 May 2013 13:47:37 +0200 |
| parents | e2e104ba42ff |
| children | ffdee6b36305 24ffb0148729 |
line wrap: on
line diff
--- a/Modules/socketmodule.c Thu May 23 05:27:38 2013 -0700 +++ b/Modules/socketmodule.c Fri May 24 13:47:37 2013 +0200 @@ -5041,6 +5041,15 @@ 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;
