Do not expect a response from the SOCKS4/4A server until it got something to respond to
authorFabian Keil <fk@fabiankeil.de>
Sat, 24 Dec 2011 15:28:45 +0000 (15:28 +0000)
committerFabian Keil <fk@fabiankeil.de>
Sat, 24 Dec 2011 15:28:45 +0000 (15:28 +0000)
Hohoho.

Fixes #3459781 reported by qqqqqw and tracked down by Lee.
Regression introduced in 3.0.18 by the usual suspect.

gateway.c

index b65991a..aedbc89 100644 (file)
--- a/gateway.c
+++ b/gateway.c
@@ -1,4 +1,4 @@
-const char gateway_rcs[] = "$Id: gateway.c,v 1.81 2011/10/23 11:21:09 fabiankeil Exp $";
+const char gateway_rcs[] = "$Id: gateway.c,v 1.82 2011/10/23 11:21:28 fabiankeil Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/gateway.c,v $
@@ -808,6 +808,13 @@ static jb_socket socks4_connect(const struct forward_spec * fwd,
       /* The error an its reason have already been logged by connect_to()  */
       return(JB_INVALID_SOCKET);
    }
+   else if (write_socket(sfd, (char *)c, csiz))
+   {
+      errstr = "SOCKS4 negotiation write failed.";
+      log_error(LOG_LEVEL_CONNECT, "socks4_connect: %s", errstr);
+      err = 1;
+      close_socket(sfd);
+   }
    else if (!data_is_available(sfd, csp->config->socket_timeout))
    {
       if (socket_is_still_alive(sfd))
@@ -822,13 +829,6 @@ static jb_socket socks4_connect(const struct forward_spec * fwd,
       err = 1;
       close_socket(sfd);
    }
-   else if (write_socket(sfd, (char *)c, csiz))
-   {
-      errstr = "SOCKS4 negotiation write failed.";
-      log_error(LOG_LEVEL_CONNECT, "socks4_connect: %s", errstr);
-      err = 1;
-      close_socket(sfd);
-   }
    else if (read_socket(sfd, buf, sizeof(buf)) != sizeof(*s))
    {
       errstr = "SOCKS4 negotiation read failed.";