summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRobey Pointer <robey@twitter.com>2009-07-19 16:00:39 -0700
committerRobey Pointer <robey@twitter.com>2009-07-19 16:00:39 -0700
commit15f4bdb10576fc0fc49da926121d88a497a5a983 (patch)
treea7a10cf164890d37b4c2af69e077033e4e937faf
parentfe35f44f2e010c41411587817ccdc998d27168ab (diff)
patch from andreux fort: add a timeout to the key exchange, so that if the remote side doesn't ever answer, eventually we give up. bug #378511
-rw-r--r--paramiko/transport.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/paramiko/transport.py b/paramiko/transport.py
index 63a2a27f..c6d2401c 100644
--- a/paramiko/transport.py
+++ b/paramiko/transport.py
@@ -338,6 +338,7 @@ class Transport (threading.Thread):
self.saved_exception = None
self.clear_to_send = threading.Event()
self.clear_to_send_lock = threading.Lock()
+ self.clear_to_send_timeout = 30.0
self.log_name = 'paramiko.transport'
self.logger = util.get_logger(self.log_name)
self.packetizer.set_log(self.logger)
@@ -1402,6 +1403,7 @@ class Transport (threading.Thread):
send a message, but block if we're in key negotiation. this is used
for user-initiated requests.
"""
+ start = time.time()
while True:
self.clear_to_send.wait(0.1)
if not self.active:
@@ -1411,6 +1413,8 @@ class Transport (threading.Thread):
if self.clear_to_send.isSet():
break
self.clear_to_send_lock.release()
+ if time.time() > start + self.clear_to_send_timeout:
+ raise SSHException('Key-exchange timed out waiting for key negotiation')
try:
self._send_message(data)
finally: