From: Martin v. Löwis Date: Tue, 5 Aug 2003 06:26:46 +0000 (+0000) Subject: Patch #781722: Reject AF_INET6 if IPv6 is disabled. X-Git-Tag: v2.3.1~189 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=777f49b549d09ce17748ef8e13e76f038cd05dde;p=thirdparty%2FPython%2Fcpython.git Patch #781722: Reject AF_INET6 if IPv6 is disabled. --- diff --git a/Misc/NEWS b/Misc/NEWS index 40fd8fb2399d..d46a5e20df39 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -15,6 +15,9 @@ Core and builtins Extension modules ----------------- +- Patch #781722: Gracefully reject AF_INET6 in socket.inet_pton + if IPv6 is disabled. + Library ------- diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index 0884d9dcabcb..d40233902e9e 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -2962,6 +2962,14 @@ socket_inet_pton(PyObject *self, PyObject *args) return NULL; } +#ifndef ENABLE_IPV6 + if(af == AF_INET6) { + PyErr_SetString(socket_error, + "can't use AF_INET6, IPv6 is disabled"); + return NULL; + } +#endif + retval = inet_pton(af, ip, packed); if (retval < 0) { PyErr_SetFromErrno(socket_error);