]> granicus.if.org Git - curl/commitdiff
socks.c: display the hostname returned by the SOCKS5 proxy server
authorMarc Hoersken <info@marc-hoersken.de>
Sat, 20 Aug 2016 19:38:09 +0000 (21:38 +0200)
committerMarc Hoersken <info@marc-hoersken.de>
Sat, 20 Aug 2016 19:38:43 +0000 (21:38 +0200)
Instead of displaying the requested hostname the one returned
by the SOCKS5 proxy server is used in case of connection error.
The requested hostname is displayed earlier in the connection sequence.

The upper-value of the port is moved to a temporary variable and
replaced with a 0-byte to make sure the hostname is 0-terminated.

lib/socks.c

index 01607bbaf5fe9a2687c6d3ab764c6e5ae0584bb0..1c01a0b93d45b3e7306615887f0922d5c3a8a5ea 100644 (file)
@@ -734,12 +734,15 @@ CURLcode Curl_SOCKS5(const char *proxy_name,
             (unsigned char)socksreq[1]);
     }
     else if(socksreq[3] == 3) {
+      unsigned char port_upper = (unsigned char)socksreq[len - 2];
+      socksreq[len - 2] = 0;
       failf(data,
             "Can't complete SOCKS5 connection to %s:%d. (%d)",
-            hostname,
-            (((unsigned char)socksreq[len - 2] << 8) |
+            (char *)&socksreq[5],
+            ((port_upper << 8) |
              (unsigned char)socksreq[len - 1]),
             (unsigned char)socksreq[1]);
+      socksreq[len - 2] = port_upper;
     }
     else if(socksreq[3] == 4) {
       failf(data,