From: Stefan Eissing Date: Mon, 6 Oct 2025 12:08:07 +0000 (+0200) Subject: socks: handle premature close X-Git-Tag: rc-8_17_0-1~84 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=089afd78cb5897adf5a42d8ccff01d7c32c8fada;p=thirdparty%2Fcurl.git socks: handle premature close When expecting to receive a number of bytes during socks connect, treat an early connection close as error. Reported-by: Joshua Rogers Closes #18883 --- diff --git a/lib/socks.c b/lib/socks.c index ba7b28d04a..e7e545442a 100644 --- a/lib/socks.c +++ b/lib/socks.c @@ -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;