python/dist/src/Modules socketmodule.c, 1.311, 1.311.2.1
Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7366/Modules Modified Files: Tag: release24-maint socketmodule.c Log Message: backport patch [ 756021 ] Allow socket.inet_aton("255.255.255.255") on Windows Index: socketmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/socketmodule.c,v retrieving revision 1.311 retrieving revision 1.311.2.1 diff -u -d -r1.311 -r1.311.2.1 --- socketmodule.c 7 Nov 2004 14:24:25 -0000 1.311 +++ socketmodule.c 26 Aug 2005 08:33:28 -0000 1.311.2.1 @@ -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); + /* 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));
participants (1)
-
birkenfeldīŧ users.sourceforge.net