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
This commit is contained in:
Stefan Eissing 2025-10-06 14:08:07 +02:00 committed by Daniel Stenberg
parent 4a6bdd5899
commit 089afd78cb
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2

View 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;