Mercurial > cpython-lru_cache-weakref
diff Modules/socketmodule.c @ 35452:59a63b09a4c2 2.4
backport patch [ 756021 ] Allow socket.inet_aton("255.255.255.255") on Windows
| author | Georg Brandl <georg@python.org> |
|---|---|
| date | Fri, 26 Aug 2005 08:33:28 +0000 |
| parents | 0d4ecc31cfd8 |
| children | 57f630a9de26 |
line wrap: on
line diff
--- a/Modules/socketmodule.c Fri Aug 26 06:43:16 2005 +0000 +++ b/Modules/socketmodule.c Fri Aug 26 08:33:28 2005 +0000 @@ -3238,14 +3238,19 @@ return NULL; #else /* ! HAVE_INET_ATON */ - /* XXX Problem here: inet_aton('255.255.255.255') raises - an exception while it should be a valid address. */ - packed_addr = inet_addr(ip_addr); - - if (packed_addr == INADDR_NONE) { /* invalid address */ - PyErr_SetString(socket_error, - "illegal IP address string passed to inet_aton"); - return NULL; + /* special-case this address as inet_addr might return INADDR_NONE + * for this */ + if (strcmp(ip_addr, "255.255.255.255") == 0) { + packed_addr = 0xFFFFFFFF; + } else { + + packed_addr = inet_addr(ip_addr); + + if (packed_addr == INADDR_NONE) { /* invalid address */ + PyErr_SetString(socket_error, + "illegal IP address string passed to inet_aton"); + return NULL; + } } return PyString_FromStringAndSize((char *) &packed_addr, sizeof(packed_addr));
