]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
socks: fix expected length of SOCKS5 reply
authorCherish98 <66007047+Cherish98@users.noreply.github.com>
Fri, 5 Jun 2020 17:36:11 +0000 (17:36 +0000)
committerDaniel Stenberg <daniel@haxx.se>
Fri, 5 Jun 2020 21:20:10 +0000 (23:20 +0200)
Commit 4a4b63d forgot to set the expected SOCKS5 reply length when the
reply ATYP is X'01'. This resulted in erroneously expecting more bytes
when the request length is greater than the reply length (e.g., when
remotely resolving the hostname).

Closes #5527

lib/socks.c

index 6031096f957eca6b42a9a5e7685b7e140a37e481..98b7818d84305a15d3c2708484446a40c7992bb4 100644 (file)
@@ -935,6 +935,13 @@ CURLcode Curl_SOCKS5(const char *proxy_user,
       /* IPv6 */
       len = 4 + 16 + 2;
     }
+    else if(socksreq[3] == 1) {
+      len = 4 + 4 + 2;
+    }
+    else {
+      failf(data, "SOCKS5 reply has wrong address type.");
+      return CURLE_COULDNT_CONNECT;
+    }
 
     /* At this point we already read first 10 bytes */
 #if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)