]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
libssh2: limit time a disconnect can take to 1 second
authorDaniel Stenberg <daniel@haxx.se>
Thu, 17 Jun 2021 08:25:53 +0000 (10:25 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 17 Jun 2021 15:06:31 +0000 (17:06 +0200)
Closes #7271

lib/vssh/libssh2.c

index 8a6345b948735bda670db105caffe59cfc616b7d..ec94747090300dc8f1495ffe4089e1ec442a6790 100644 (file)
@@ -2938,6 +2938,7 @@ static CURLcode ssh_block_statemach(struct Curl_easy *data,
 {
   struct ssh_conn *sshc = &conn->proto.sshc;
   CURLcode result = CURLE_OK;
+  struct curltime dis = Curl_now();
 
   while((sshc->state != SSH_STOP) && !result) {
     bool block;
@@ -2962,6 +2963,12 @@ static CURLcode ssh_block_statemach(struct Curl_easy *data,
         return CURLE_OPERATION_TIMEDOUT;
       }
     }
+    else if(Curl_timediff(now, dis) > 1000) {
+      /* disconnect timeout */
+      failf(data, "Disconnect timed out");
+      result = CURLE_OK;
+      break;
+    }
 
     if(block) {
       int dir = libssh2_session_block_directions(sshc->ssh_session);