From 088398af06f26d8df0d008f8cfb1cda422a4a4fc Mon Sep 17 00:00:00 2001 From: Stefan Eissing Date: Wed, 25 Jun 2025 10:25:53 +0200 Subject: [PATCH] make socks asserts on hostname and port earlier to catch where fuzzer crashes --- lib/connect.c | 4 ++++ lib/socks.c | 7 +++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/connect.c b/lib/connect.c index 07e334ff2a..f41403c316 100644 --- a/lib/connect.c +++ b/lib/connect.c @@ -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, diff --git a/lib/socks.c b/lib/socks.c index 08286271c3..092f9341bf 100644 --- a/lib/socks.c +++ b/lib/socks.c @@ -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);