/*
* 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
addr = name_lookup(hostname, port, &dummy_realhost, conf, addressfamily);
if ((err = sk_addr_error(addr)) != NULL) {
sk_addr_free(addr);
+ sfree(dummy_realhost);
return err;
}
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,
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;