This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients ezio.melotti, maker, santoso.wijaya, vstinner
Date 2012-10-12.21:59:41
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1350079181.53.0.65104086427.issue16201@psf.upfronthosting.co.za>
In-reply-to
Content
> 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 getaddrinfo().

If you consider that '192.168.1.1  ' is an invalid name, you should report the issue to the vendor of the C library of your OS.

--

On Linux, the "issue" is also present in inet_ntoa():

$ python
Python 2.7.3 (default, Jul 24 2012, 11:41:40) 
[GCC 4.6.3 20120306 (Red Hat 4.6.3-2)] on linux2
>>> import ctypes
>>> buffer=ctypes.create_string_buffer(128)
>>> libc=ctypes.cdll.LoadLibrary("libc.so.6")

>>> libc.inet_aton(b"127.0.0.1", ctypes.byref(buffer))
1
>>> buffer.raw[:4]
'\x7f\x00\x00\x01'

>>> libc.inet_aton(b"127.0.0.2   ", ctypes.byref(buffer))
1
>>> buffer.raw[:4]
'\x7f\x00\x00\x02'

The source code of the inet_aton() function of the GNU libc:

http://sourceware.org/git/?p=glibc.git;a=blob;f=resolv/inet_addr.c;h=144b87a74c1aef62779862e78e5f87e18e66ee9e;hb=HEAD#l108

Website of the GNU libc:
http://www.gnu.org/software/libc/
History
Date User Action Args
2012-10-12 21:59:41vstinnersetrecipients: + vstinner, ezio.melotti, santoso.wijaya, maker
2012-10-12 21:59:41vstinnersetmessageid: <1350079181.53.0.65104086427.issue16201@psf.upfronthosting.co.za>
2012-10-12 21:59:41vstinnerlinkissue16201 messages
2012-10-12 21:59:41vstinnercreate