1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-02 03:52:49 -05:00

Remove downstream remote port forwardings in ssh.c too.

Another piece of half-finished machinery that I can't have tested
properly when I set up connection sharing: I had the function
ssh_alloc_sharing_rportfwd which is how sshshare.c asks ssh.c to start
sending it channel-open requests for a given remote forwarded port,
but I had no companion function that removes one of those requests
again when a downstream remote port forwarding goes away (either by
mid-session cancel-tcpip-forward or by the whole downstream
disconnecting).

As a result, the _second_ attempt to set up the same remote port
forwarding, after a sharing downstream had done so once and then
stopped, would quietly fail.
This commit is contained in:
Simon Tatham
2018-06-03 07:54:00 +01:00
parent 314c8f5270
commit 3f1f7c3ce7
3 changed files with 25 additions and 0 deletions

View File

@ -857,6 +857,8 @@ static void share_try_cleanup(struct ssh_sharing_connstate *cs)
"cleanup after downstream went away");
strbuf_free(packet);
ssh_remove_sharing_rportfwd(cs->parent->ssh,
fwd->host, fwd->port, cs);
share_remove_forwarding(cs, fwd);
i--; /* don't accidentally skip one as a result */
}
@ -1392,6 +1394,12 @@ static void share_got_pkt_from_downstream(struct ssh_sharing_connstate *cs,
"", 0, NULL);
}
} else {
/*
* Tell ssh.c to stop sending us channel-opens for
* this forwarding.
*/
ssh_remove_sharing_rportfwd(cs->parent->ssh, host, port, cs);
/*
* Pass the cancel request on to the SSH server, but
* set want_reply even if it wasn't originally set, so