From: Fabian Keil Date: Sun, 9 Jan 2011 12:08:52 +0000 (+0000) Subject: Let socks4_connect enforce the socket timeout for the negotiation response as well. X-Git-Tag: v_3_0_18~359 X-Git-Url: http://www.privoxy.org/gitweb/?p=privoxy.git;a=commitdiff_plain;h=eeccd16536eb2f257a944d26767c75ebd56a10d2 Let socks4_connect enforce the socket timeout for the negotiation response as well. --- diff --git a/gateway.c b/gateway.c index bd6a3d9d..6ccfcbca 100644 --- 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.";