mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-10 09:58:01 +00:00
Port forwarding bug fix: we were unable to handle receiving
CHANNEL_OPEN_FAILURE messages, which occur when the remote side is unable to open a forwarded network connection we have requested. (It seems they _don't_ show up if you get something mundane like Connection Refused - the channel is cheerfully opened and immediately slammed shut - but they do if you try to connect to a host that doesn't even exist. Try forwarding a port to frogwibbler:4800 and see what you get.) [originally from svn r1213]
This commit is contained in:
parent
448c1a085a
commit
254f50974e
28
ssh.c
28
ssh.c
@ -2841,6 +2841,19 @@ static void ssh1_protocol(unsigned char *in, int inlen, int ispkt)
|
||||
pfd_confirm(c->u.pfd.s);
|
||||
}
|
||||
|
||||
} else if (pktin.type == SSH1_MSG_CHANNEL_OPEN_FAILURE) {
|
||||
unsigned int remoteid = GET_32BIT(pktin.body);
|
||||
unsigned int localid = GET_32BIT(pktin.body+4);
|
||||
struct ssh_channel *c;
|
||||
|
||||
c = find234(ssh_channels, &remoteid, ssh_channelfind);
|
||||
if (c && c->type == CHAN_SOCKDATA_DORMANT) {
|
||||
logevent("Forwarded connection refused by server");
|
||||
pfd_close(c->u.pfd.s);
|
||||
del234(ssh_channels, c);
|
||||
sfree(c);
|
||||
}
|
||||
|
||||
} else if (pktin.type == SSH1_MSG_CHANNEL_CLOSE ||
|
||||
pktin.type == SSH1_MSG_CHANNEL_CLOSE_CONFIRMATION) {
|
||||
/* Remote side closes a channel. */
|
||||
@ -4773,6 +4786,21 @@ static void do_ssh2_authconn(unsigned char *in, int inlen, int ispkt)
|
||||
c->v.v2.remmaxpkt = ssh2_pkt_getuint32();
|
||||
bufchain_init(&c->v.v2.outbuffer);
|
||||
pfd_confirm(c->u.pfd.s);
|
||||
} else if (pktin.type == SSH2_MSG_CHANNEL_OPEN_FAILURE) {
|
||||
unsigned i = ssh2_pkt_getuint32();
|
||||
struct ssh_channel *c;
|
||||
c = find234(ssh_channels, &i, ssh_channelfind);
|
||||
if (!c)
|
||||
continue; /* nonexistent channel */
|
||||
if (c->type != CHAN_SOCKDATA_DORMANT)
|
||||
continue; /* dunno why they're failing this */
|
||||
|
||||
logevent("Forwarded connection refused by server");
|
||||
|
||||
pfd_close(c->u.pfd.s);
|
||||
|
||||
del234(ssh_channels, c);
|
||||
sfree(c);
|
||||
} else if (pktin.type == SSH2_MSG_CHANNEL_OPEN) {
|
||||
char *type;
|
||||
int typelen;
|
||||
|
Loading…
Reference in New Issue
Block a user