[Python-bugs-list] [ python-Bugs-565747 ] crash on gethostbyaddr
noreply@sourceforge.net
noreply@sourceforge.net
Sun, 28 Jul 2002 09:12:10 -0700
Bugs item #565747, was opened at 2002-06-07 12:11
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=565747&group_id=5470
Category: Python Library
Group: Python 2.2.1
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Joerg Beyer (jbeyer)
Assigned to: Martin v. Löwis (loewis)
Summary: crash on gethostbyaddr
Initial Comment:
if python is compiled with --disable-ipv6, AND the
host has ipv6 enabled. Then calling
python2.2 -c "import socket; print
socket.gethostbyaddr('::0')"
you get a
Segmentation fault
This is caused by Python copying the V6 information
returned by the OS into the V4 struct of Python.See the
attached diff for socketmodule.c for a fix.
Alternatively, one could move the memcpy at the end of
setipaddr() into the switch, so that if the system
returns "unknown address family", the invalid copy is
not executed.
----------------------------------------------------------------------
>Comment By: Martin v. Löwis (loewis)
Date: 2002-07-28 18:12
Message:
Logged In: YES
user_id=21627
Thanks for the patch; committed as socketmodule.c 1.238 and
1.200.6.7.
----------------------------------------------------------------------
Comment By: Joerg Beyer (jbeyer)
Date: 2002-06-11 13:02
Message:
Logged In: YES
user_id=103570
Martin, I took your fix and changed the "sizeof(addr)" to
"sizeof(*addr)" ot the explicit type. With this combined
patch my testcases work again.
./python -c "import urllib;
urllib.urlopen('https://kalender.web.de/').read(256)"
(of course, you could use any rechable ssl webserver)
Could you test my testcase with your version? If it fails,
could you
test the "socketmodule.c.diff2" patch?
Thanks for your help.
Joerg
----------------------------------------------------------------------
Comment By: Martin v. Löwis (loewis)
Date: 2002-06-11 07:45
Message:
Logged In: YES
user_id=21627
Sorry about that; the patch is attached now.
----------------------------------------------------------------------
Comment By: Jürgen Hermann (jhermann)
Date: 2002-06-09 13:34
Message:
Logged In: YES
user_id=39128
Martin, the attachment didn't make it to the system, it seems.
----------------------------------------------------------------------
Comment By: Martin v. Löwis (loewis)
Date: 2002-06-09 11:04
Message:
Logged In: YES
user_id=21627
Jürgen, can you please try the attached sock.diff? This is a
slightly corrected version of Jörg's patch (IMO). I could
not observe the problem you've seen with Jörg's patch on a
SuSE 8.0 installation.
As for IPv6 not working on a SuSE 7.0 system: This is very
possible. Python requires the RFC2553 API, it might be that
this was not available in the glibc version that shipped
with SuSE 7.0.
----------------------------------------------------------------------
Comment By: Jürgen Hermann (jhermann)
Date: 2002-06-07 16:24
Message:
Logged In: YES
user_id=39128
We found out a little more: after applying the fix, we get
"unsupported address family" exceptions for IPV6 addresses,
but also we cannot open sockets any more ("could not
connect" exceptions by urllib for any URL). So the fix is
not complete. BTW, the bug appears with Python 2.2, Python
2.0 and 2.1 _do_ work on the same machine.
Another piece of information: we tried to --enable-ipv6 on
that machine (SuSE 7.0, gcc 2.9.95), and got this:
gcc -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -I.
-I./Include -DHAVE_CONFIG_H
-DUSE_SSL -I/netsite/include -I/netsite/include/openssl -c
./Modules/socketmodul
./Modules/socketmodule.c: In function `makesockaddr':
./Modules/socketmodule.c:733: structure has no member named
`sin6_scope_id'
./Modules/socketmodule.c: In function `getsockaddrarg':
./Modules/socketmodule.c:846: structure has no member named
`sin6_scope_id'
./Modules/socketmodule.c: In function `PySocket_getnameinfo':
./Modules/socketmodule.c:2598: structure has no member named
`sin6_scope_id'
make: *** [Modules/socketmodule.o] Error 1
Don't know whether that is SuSE 7.0's fault.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=565747&group_id=5470