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.

classification
Title: crash on gethostbyaddr
Type: Stage:
Components: Library (Lib) Versions: Python 2.2
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: loewis Nosy List: jbeyer, jhermann, loewis
Priority: normal Keywords:

Created on 2002-06-07 10:11 by jbeyer, last changed 2022-04-10 16:05 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
socketmodule.c.diff jbeyer, 2002-06-07 10:11 diff for bugfix
sock.diff loewis, 2002-06-11 05:45
socketmodule.c.diff2 jbeyer, 2002-06-11 11:03 my 2nd version of the pacht (against a clean socketmodule.c)
Messages (7)
msg11087 - (view) Author: Joerg Beyer (jbeyer) Date: 2002-06-07 10:11
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.
msg11088 - (view) Author: Jürgen Hermann (jhermann) Date: 2002-06-07 14:24
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.
msg11089 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2002-06-09 09:04
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.
msg11090 - (view) Author: Jürgen Hermann (jhermann) Date: 2002-06-09 11:34
Logged In: YES 
user_id=39128

Martin,  the attachment didn't make it to the system, it seems.
msg11091 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2002-06-11 05:45
Logged In: YES 
user_id=21627

Sorry about that; the patch is attached now.
msg11092 - (view) Author: Joerg Beyer (jbeyer) Date: 2002-06-11 11:02
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
msg11093 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2002-07-28 16:12
Logged In: YES 
user_id=21627

Thanks for the patch; committed as socketmodule.c 1.238 and
1.200.6.7.
History
Date User Action Args
2022-04-10 16:05:23adminsetgithub: 36707
2002-06-07 10:11:49jbeyercreate