]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
socks: handle premature close
authorStefan Eissing <stefan@eissing.org>
Mon, 6 Oct 2025 12:08:07 +0000 (14:08 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 7 Oct 2025 11:14:50 +0000 (13:14 +0200)
When expecting to receive a number of bytes during socks connect,
treat an early connection close as error.

Reported-by: Joshua Rogers
Closes #18883

lib/socks.c

index ba7b28d04a01f89be47184f9206bdef1dd43a00f..e7e545442a9ad7f7188c69a832e2b43e84d4534d 100644 (file)
@@ -254,8 +254,14 @@ static CURLproxycode socks_recv(struct socks_state *sx,
             curl_easy_strerror(result));
       return CURLPX_RECV_CONNECT;
     }
-    else if(!nread) /* EOF */
+    else if(!nread) { /* EOF */
+      if(Curl_bufq_len(&sx->iobuf) < min_bytes) {
+        failf(data, "Failed to receive SOCKS response, "
+              "proxy closed connection");
+        return CURLPX_RECV_CONNECT;
+      }
       break;
+    }
   }
   *done = TRUE;
   return CURLPX_OK;