Skip to content

Commit add6111

Browse files
authored
Fix 100% CPU spin in TLS connections after timeout (#683)
1 parent c4d67ba commit add6111

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

HISTORY.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Version: 2.2.0 - XXXX-XX-XX
1111

1212
* #676: Always return 200 for the ``OPTS UTF8`` and ``OPTS UTF-8 ON`` commands
1313
to ensure correct FTP client compatibility when UTF-8 is supported.
14+
* #683: Fix 100% CPU spin in TLS connections after timeout
1415

1516
**Compatibility notes**
1617

pyftpdlib/handlers/ftps/control.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from OpenSSL import SSL
88

99
from pyftpdlib.handlers.ftp.control import FTPHandler
10+
from pyftpdlib.log import logger
1011

1112
from .data import TLS_DTPHandler
1213
from .ssl import SSLConnectionMixin
@@ -160,6 +161,16 @@ def process_command(self, cmd, *args, **kwargs):
160161
return
161162
FTPHandler.process_command(self, cmd, *args, **kwargs)
162163

164+
def handle_timeout(self):
165+
"""Called when client does not send any command within the time
166+
specified in <timeout> attribute."""
167+
if self._ssl_accepting:
168+
logger.info("SSL handshake timeout")
169+
# SSL handshake not complete - can't send response, just close
170+
self.close()
171+
else:
172+
super().handle_timeout()
173+
163174
def close(self):
164175
SSLConnectionMixin.close(self)
165176
FTPHandler.close(self)

0 commit comments

Comments
 (0)