Skip to content

Commit

Permalink
socks: socks4 fix host resolve regression
Browse files Browse the repository at this point in the history
1. The socks4 state machine was broken in the host resolving phase

2. The code now insists on IPv4-only when using SOCKS4 as the protocol
only supports that.

Regression from #4907 and 4a4b63d, shipped in 7.69.0

Reported-by: amishmm on github
Bug: #5053 (comment)
  • Loading branch information
bagder committed Mar 8, 2020
1 parent 0a04dc4 commit 30b0365
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/socks.c
Expand Up @@ -205,6 +205,8 @@ CURLcode Curl_SOCKS4(const char *proxy_user,

switch(sx->state) {
case CONNECT_SOCKS_INIT:
/* SOCKS4 can only do IPv4, insist! */
conn->ip_version = CURL_IPRESOLVE_V4;
if(conn->bits.httpproxy)
infof(conn->data, "SOCKS4%s: connecting to HTTP proxy %s port %d\n",
protocol4a ? "a" : "", hostname, remote_port);
Expand Down Expand Up @@ -261,8 +263,8 @@ CURLcode Curl_SOCKS4(const char *proxy_user,
}
else {
result = Curl_resolv_check(data->conn, &dns);
/* stay in the state or error out */
return result;
if(!dns)
return result;
}
/* FALLTHROUGH */
CONNECT_RESOLVED:
Expand Down

0 comments on commit 30b0365

Please sign in to comment.