Issue 754870: SSL crash interpreter on error (original) (raw)
When testing bug 739909, I provoked this bug. To reproduce:
./python # need to be root to listen on privileged port
from socket import * s = socket(AF_INET, SOCK_STREAM) s.bind(('', 993)) s.listen(5) s.accept()
now go to another window and do:
$ ./python
import imaplib imaplib.IMAP4_SSL('localhost')
this will wait for the first (root) interpreter
exit from first/root interpreter and SSL will crash
There is a stack trace below.
The problem is that in PySSL_SetError(), there is an assumption that obj->Socket exists, but it doesn't in this case.
The attached patch fixes the crash, but I'm not certain it is correct.
#0 0x4046eaba in PySSL_SetError (obj=0x81e0718, ret=-1) at /home/neal/build/python/2_3/Modules/_ssl.c:118 #1 0x4046efed in newPySSLObject (Sock=0x4013f9c8, key_file=0x0, cert_file=0x0) at /home/neal/build/python/2_3/Modules/_ssl.c:259 #2 0x4046f181 in PySocket_ssl (self=0x0, args=0x403e4df4) at /home/neal/build/python/2_3/Modules/_ssl.c:296