[issue16201] socket.gethostbyname incorrectly parses ip

2013-09-14 Thread Charles-François Natali
Charles-François Natali added the comment: Closing, thanks for the report! -- resolution: -> fixed stage: patch review -> committed/rejected status: open -> closed versions: -Python 2.7, Python 3.3 ___ Python tracker

[issue16201] socket.gethostbyname incorrectly parses ip

2013-09-14 Thread Charles-François Natali
Charles-François Natali added the comment: Alright, I committed it to default. I don't think it should go into 2.7 or 3.3, since it's more an enhancement than a bug fix. -- ___ Python tracker _

[issue16201] socket.gethostbyname incorrectly parses ip

2013-09-13 Thread Roundup Robot
Roundup Robot added the comment: New changeset 540a9c69c2ea by Charles-François Natali in branch 'default': Issue #16201: socket: Use inet_pton()/inet_addr() instead of ad-hoc parsing for http://hg.python.org/cpython/rev/540a9c69c2ea -- nosy: +python-dev

[issue16201] socket.gethostbyname incorrectly parses ip

2013-09-04 Thread Antoine Pitrou
Changes by Antoine Pitrou : -- versions: -Python 3.1, Python 3.2, Python 3.5 ___ Python tracker ___ ___ Python-bugs-list mailing list

[issue16201] socket.gethostbyname incorrectly parses ip

2013-09-04 Thread Antoine Pitrou
Antoine Pitrou added the comment: Perhaps you could add tests for the broadcast special cases? -- ___ Python tracker ___ ___ Python-bu

[issue16201] socket.gethostbyname incorrectly parses ip

2013-09-03 Thread Charles-François Natali
Charles-François Natali added the comment: Here's an updated patch with new tests. It passes the regression test, and yields noticable performance improvements for IPv6: before: $ ./python -m timeit -s "import socket; s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM); DATA = b'hello'" "s.se

[issue16201] socket.gethostbyname incorrectly parses ip

2013-08-29 Thread Michele Orrù
Michele Orrù added the comment: Cool, thanks for pointing the correct library function. Tested on my machine - Debian 3.9 x86_64 GNU/Linux. -- ___ Python tracker ___ __

[issue16201] socket.gethostbyname incorrectly parses ip

2013-08-29 Thread Charles-François Natali
Changes by Charles-François Natali : Removed file: http://bugs.python.org/file31506/parse_inet.diff ___ Python tracker ___ ___ Python-bugs-lis

[issue16201] socket.gethostbyname incorrectly parses ip

2013-08-29 Thread Charles-François Natali
Charles-François Natali added the comment: > For Windows >= Vista, inet_pton() is available. > I'm not sure whether XP has one of them: if not, then we might keep > the hand-parsing as a fallback. Apparently, XP doesn't have inet_aton()... So I changed the code to use inet_pton() if available,

[issue16201] socket.gethostbyname incorrectly parses ip

2013-08-29 Thread Charles-François Natali
Charles-François Natali added the comment: Here's a patch using inet_pton() if available, otherwise inet_aton() if available, otherwise fallback to getaddrinfo(). This should work on every platform, but if a platform has neither inet_pton() nor inet_aton(), calling getaddrinfo() will incur an ove

[issue16201] socket.gethostbyname incorrectly parses ip

2013-08-29 Thread Charles-François Natali
Charles-François Natali added the comment: Note that for IPv6 addresses, we should just extract manually the scope ID ('%' prefix) if present. -- ___ Python tracker ___ _

[issue16201] socket.gethostbyname incorrectly parses ip

2013-08-29 Thread Charles-François Natali
Charles-François Natali added the comment: Stupid question: why use scanf()/strtol() to parse an IP address, and not simply inet_pton()/inet_aton(), which are made precisely for that purpose? inet_pton() is POSIX (it was introduced at the same time as getaddrinfo(), which is used unconditionall

[issue16201] socket.gethostbyname incorrectly parses ip

2013-08-27 Thread Michele Orrù
Michele Orrù added the comment: Ping. -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org

[issue16201] socket.gethostbyname incorrectly parses ip

2012-10-13 Thread Michele Orrù
Michele Orrù added the comment: Updated && tested on GNU/Linux (gcc). -- Added file: http://bugs.python.org/file27558/issue16201.3.patch ___ Python tracker ___ __

[issue16201] socket.gethostbyname incorrectly parses ip

2012-10-13 Thread Antoine Pitrou
Antoine Pitrou added the comment: I don't think uint32_t exists everywhere, you should use "unsigned int" instead. -- nosy: +pitrou ___ Python tracker ___ ___

[issue16201] socket.gethostbyname incorrectly parses ip

2012-10-13 Thread Michele Orrù
Michele Orrù added the comment: Reviewed with Ezio. -- Added file: http://bugs.python.org/file27550/issue16201.2.patch ___ Python tracker ___

[issue16201] socket.gethostbyname incorrectly parses ip

2012-10-13 Thread Michele Orrù
Michele Orrù added the comment: > >> Buggy due to the use of scanf at Modueles/socketmodule.c:868 > > I don't think so. The following test fails because sscanf() returns 5 > instead of 4: You are right, sorry for didn't notice. > If you consider that '192.168.1.1 ' is an invalid name, you sho

[issue16201] socket.gethostbyname incorrectly parses ip

2012-10-12 Thread STINNER Victor
STINNER Victor added the comment: > Buggy due to the use of scanf at Modueles/socketmodule.c:868 I don't think so. The following test fails because sscanf() returns 5 instead of 4: if (sscanf(name, "%d.%d.%d.%d%c", &d1, &d2, &d3, &d4, &ch) == 4 && ...) So '192.168.1.1 ' is passed to geta

[issue16201] socket.gethostbyname incorrectly parses ip

2012-10-12 Thread Michele Orrù
Changes by Michele Orrù : Added file: http://bugs.python.org/file27540/issue16201.patch ___ Python tracker ___ ___ Python-bugs-list mailing li

[issue16201] socket.gethostbyname incorrectly parses ip

2012-10-12 Thread Michele Orrù
Michele Orrù added the comment: > Attaching patch to trim leading and trailing whitespaces prior to > processing. Note that tests are incorrect: the parsing is of the form %d.%d.%d.%d%c, so the parser should accept trailing spaces. That's the same for ping iirc: $ ping "192.168.1.1" PING 1

[issue16201] socket.gethostbyname incorrectly parses ip

2012-10-11 Thread Santoso Wijaya
Santoso Wijaya added the comment: Attaching patch to trim leading and trailing whitespaces prior to processing. Incidentally, this also means: >>> socket.gethostbyname('') '0.0.0.0' >>> socket.gethostbyname(' ') Traceback (most recent call last): File "", line 1, in socket.gaierror: [Errno -

[issue16201] socket.gethostbyname incorrectly parses ip

2012-10-11 Thread Santoso Wijaya
Changes by Santoso Wijaya : -- components: +Extension Modules nosy: +santa4nt type: -> behavior versions: +Python 2.7 ___ Python tracker ___

[issue16201] socket.gethostbyname incorrectly parses ip

2012-10-11 Thread Michele Orrù
New submission from Michele Orrù: Buggy due to the use of scanf at Modueles/socketmodule.c:868 Broken from python2.7 to tip on my machine (GNU/Linux) >>> import socket [64481 refs] >>> socket.gethostbyname('4294967306.4294967296.4294967296.1') '10.0.0.1' [67764 refs] >>> socket.gethostbyname('19