Let socks4_connect enforce the socket timeout for the negotiation response as well.
authorFabian Keil <fk@fabiankeil.de>
Sun, 9 Jan 2011 12:08:52 +0000 (12:08 +0000)
committerFabian Keil <fk@fabiankeil.de>
Sun, 9 Jan 2011 12:08:52 +0000 (12:08 +0000)
gateway.c

index bd6a3d9..6ccfcbc 100644 (file)
--- a/gateway.c
+++ b/gateway.c
@@ -1,4 +1,4 @@
-const char gateway_rcs[] = "$Id: gateway.c,v 1.65 2010/04/23 11:53:48 fabiankeil Exp $";
+const char gateway_rcs[] = "$Id: gateway.c,v 1.66 2011/01/09 12:08:35 fabiankeil Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/gateway.c,v $
@@ -809,6 +809,20 @@ static jb_socket socks4_connect(const struct forward_spec * fwd,
       errstr = "connect_to failed: see logfile for details";
       err = 1;
    }
+   else if (!data_is_available(sfd, csp->config->socket_timeout))
+   {
+      if (socket_is_still_alive(sfd))
+      {
+         errstr = "SOCKS4 negotiation timed out";
+      }
+      else
+      {
+         errstr = "SOCKS4 negotiation got aborted by the server";
+      }
+      log_error(LOG_LEVEL_CONNECT, "socks4_connect: %s", errstr);
+      err = 1;
+      close_socket(sfd);
+   }
    else if (write_socket(sfd, (char *)c, csiz))
    {
       errstr = "SOCKS4 negotiation write failed.";