diff options
author | Georg Brandl <georg@python.org> | 2005-08-26 08:34:00 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2005-08-26 08:34:00 (GMT) |
commit | d2e3ba7a3595bfa4342ab30b5228d8d94d6c6a08 (patch) | |
tree | a2de338e899e726ce48edbd821e1fa8245897ecc /Modules/socketmodule.c | |
parent | 4550b8db567d08d8b8c6e6fd941b9a32369c0553 (diff) | |
download | cpython-d2e3ba7a3595bfa4342ab30b5228d8d94d6c6a08.zip cpython-d2e3ba7a3595bfa4342ab30b5228d8d94d6c6a08.tar.gz cpython-d2e3ba7a3595bfa4342ab30b5228d8d94d6c6a08.tar.bz2 |
patch [ 756021 ] Allow socket.inet_aton("255.255.255.255") on Windows
Diffstat (limited to 'Modules/socketmodule.c')
-rw-r--r-- | Modules/socketmodule.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index 3c17e9c..059153d 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -3238,14 +3238,19 @@ socket_inet_aton(PyObject *self, PyObject *args) 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); + /* 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; + 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)); |