Issue #17918: When using SSLSocket.accept(), if the SSL handshake failed on the new socket, the socket would linger indefinitely.

Thanks to Peter Saveliev for reporting.
This commit is contained in:
Antoine Pitrou 2013-05-06 22:19:48 +02:00
parent 31bc8bef63
commit f16ff7bc21
2 changed files with 19 additions and 11 deletions

View File

@ -344,6 +344,7 @@ class SSLSocket(socket):
SSL channel, and the address of the remote client.""" SSL channel, and the address of the remote client."""
newsock, addr = socket.accept(self) newsock, addr = socket.accept(self)
try:
return (SSLSocket(newsock, return (SSLSocket(newsock,
keyfile=self.keyfile, keyfile=self.keyfile,
certfile=self.certfile, certfile=self.certfile,
@ -355,6 +356,9 @@ class SSLSocket(socket):
do_handshake_on_connect=self.do_handshake_on_connect, do_handshake_on_connect=self.do_handshake_on_connect,
suppress_ragged_eofs=self.suppress_ragged_eofs), suppress_ragged_eofs=self.suppress_ragged_eofs),
addr) addr)
except socket_error as e:
newsock.close()
raise e
def makefile(self, mode='r', bufsize=-1): def makefile(self, mode='r', bufsize=-1):

View File

@ -34,6 +34,10 @@ Core and Builtins
Library Library
------- -------
- Issue #17918: When using SSLSocket.accept(), if the SSL handshake failed
on the new socket, the socket would linger indefinitely. Thanks to
Peter Saveliev for reporting.
- Issue #17289: The readline module now plays nicer with external modules - Issue #17289: The readline module now plays nicer with external modules
or applications changing the rl_completer_word_break_characters global or applications changing the rl_completer_word_break_characters global
variable. Initial patch by Bradley Froehle. variable. Initial patch by Bradley Froehle.