[Python-bugs-list] [ python-Bugs-565747 ] crash on gethostbyaddr

noreply@sourceforge.net noreply@sourceforge.net
Sun, 09 Jun 2002 04:34:26 -0700


Bugs item #565747, was opened at 2002-06-07 12:11
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=565747&group_id=5470

Category: Python Library
Group: Python 2.2.1
Status: Open
Resolution: None
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: 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: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=565747&group_id=5470