make socks asserts on hostname and port earlier to catch where fuzzer crashes

This commit is contained in:
Stefan Eissing 2025-06-25 10:25:53 +02:00
parent c8eccf074b
commit 088398af06
No known key found for this signature in database
2 changed files with 7 additions and 4 deletions

View file

@ -1297,6 +1297,8 @@ connect_sub_chain:
if(ctx->state < CF_SETUP_CNNCT_SOCKS && cf->conn->bits.socksproxy) {
/* Where do we need the SOCKS to connect to? */
if(cf->conn->bits.httpproxy) {
DEBUGASSERT(cf->conn->http_proxy.host.name);
DEBUGASSERT(cf->conn->http_proxy.port > 0);
result = Curl_cf_socks_proxy_insert_after(
cf, data, cf->conn->socks_proxy.proxytype, "HTTP proxy",
cf->conn->http_proxy.host.name, (int)cf->conn->http_proxy.port,
@ -1313,6 +1315,8 @@ connect_sub_chain:
cf->conn->bits.conn_to_port ? cf->conn->conn_to_port :
cf->conn->remote_port;
DEBUGASSERT(sx_hostname);
DEBUGASSERT(sx_remote_port > 0);
result = Curl_cf_socks_proxy_insert_after(
cf, data, cf->conn->socks_proxy.proxytype, NULL,
sx_hostname, sx_remote_port,

View file

@ -1105,8 +1105,6 @@ static CURLcode socks_proxy_cf_connect(struct Curl_cfilter *cf,
* but ignore the "connect to port" (use the secondary port)
*/
sxstate(sx, data, CONNECT_SOCKS_INIT);
DEBUGASSERT(sx->hostname);
DEBUGASSERT(sx->remote_port > 0);
}
result = connect_SOCKS(cf, sx, data);
@ -1223,16 +1221,17 @@ CURLcode Curl_cf_socks_proxy_insert_after(struct Curl_cfilter *cf_at,
if(!sx)
return CURLE_OUT_OF_MEMORY;
result = Curl_cf_create(&cf, &Curl_cft_socks_proxy, NULL);
result = Curl_cf_create(&cf, &Curl_cft_socks_proxy, sx);
if(!result) {
Curl_conn_cf_insert_after(cf_at, cf);
sx->proxy_type = proxy_type;
sx->remote_type = remote_type;
sx->hostname = remote_host;
sx->remote_port = remote_port;
DEBUGASSERT(sx->hostname);
DEBUGASSERT(sx->remote_port > 0);
sx->proxy_user = proxy_user;
sx->proxy_password = proxy_password;
cf->ctx = sx;
sx = NULL;
}
free(sx);