X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=portfwd.c;h=b14458b931e0ac0f639993f5f9ee18189eee4cd6;hb=6f6e9db932589470975ecc23261cd57eb9e710be;hp=264198fb2129299806be52a0cb0b359d61ec05df;hpb=08d46fca517e292ae1671c4daa994af99d8c0a1d;p=PuTTY.git diff --git a/portfwd.c b/portfwd.c index 264198fb..b14458b9 100644 --- a/portfwd.c +++ b/portfwd.c @@ -87,7 +87,17 @@ static int pfd_closing(Plug plug, const char *error_msg, int error_code, /* * Socket error. Slam the connection instantly shut. */ - sshfwd_unclean_close(pr->c); + if (pr->c) { + sshfwd_unclean_close(pr->c, error_msg); + } else { + /* + * We might not have an SSH channel, if a socket error + * occurred during SOCKS negotiation. If not, we must + * clean ourself up without sshfwd_unclean_close's call + * back to pfd_close. + */ + pfd_close(pr->s); + } } else { /* * Ordinary EOF received on socket. Send an EOF on the SSH @@ -401,7 +411,7 @@ const char *pfd_newconnect(Socket *s, char *hostname, int port, called when someone connects to the local port */ -static int pfd_accepting(Plug p, OSSocket sock) +static int pfd_accepting(Plug p, accept_fn_t constructor, accept_ctx_t ctx) { static const struct plug_function_table fn_table = { pfd_log, @@ -421,7 +431,7 @@ static int pfd_accepting(Plug p, OSSocket sock) pr->c = NULL; pr->backhandle = org->backhandle; - pr->s = s = sk_register(sock, (Plug) pr); + pr->s = s = constructor(ctx, (Plug) pr); if ((err = sk_socket_error(s)) != NULL) { free_portfwd_private(pr); return err != NULL;