1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-10 09:58:01 +00:00

Handle incoming SSH2_MSG_CHANNEL_REQUEST (by refusing all requests).

Should have done this ages ago; the OpenSSH 3.0 ClientAliveInterval
mechanism requires it so now it's really necessary.

[originally from svn r1380]
This commit is contained in:
Simon Tatham 2001-11-13 22:06:37 +00:00
parent 45945b2726
commit 7530a9905a

42
ssh.c
View File

@ -4797,8 +4797,6 @@ static void do_ssh2_authconn(unsigned char *in, int inlen, int ispkt)
ssh_state = SSH_STATE_CLOSED; ssh_state = SSH_STATE_CLOSED;
logevent("Received disconnect message"); logevent("Received disconnect message");
crReturnV; crReturnV;
} else if (pktin.type == SSH2_MSG_CHANNEL_REQUEST) {
continue; /* exit status et al; ignore (FIXME?) */
} else if (pktin.type == SSH2_MSG_CHANNEL_EOF) { } else if (pktin.type == SSH2_MSG_CHANNEL_EOF) {
unsigned i = ssh2_pkt_getuint32(); unsigned i = ssh2_pkt_getuint32();
struct ssh_channel *c; struct ssh_channel *c;
@ -4917,6 +4915,46 @@ static void do_ssh2_authconn(unsigned char *in, int inlen, int ispkt)
del234(ssh_channels, c); del234(ssh_channels, c);
sfree(c); sfree(c);
} else if (pktin.type == SSH2_MSG_CHANNEL_REQUEST) {
unsigned localid;
char *type;
int typelen, want_reply;
struct ssh_channel *c;
localid = ssh2_pkt_getuint32();
ssh2_pkt_getstring(&type, &typelen);
want_reply = ssh2_pkt_getbool();
/*
* First, check that the channel exists. Otherwise,
* we can instantly disconnect with a rude message.
*/
c = find234(ssh_channels, &localid, ssh_channelfind);
if (!c) {
char buf[80];
sprintf(buf, "Received channel request for nonexistent"
" channel %d", localid);
logevent(buf);
ssh2_pkt_init(SSH2_MSG_DISCONNECT);
ssh2_pkt_adduint32(SSH2_DISCONNECT_BY_APPLICATION);
ssh2_pkt_addstring(buf);
ssh2_pkt_addstring("en"); /* language tag */
ssh2_pkt_send();
connection_fatal(buf);
ssh_state = SSH_STATE_CLOSED;
crReturnV;
}
/*
* We don't recognise any form of channel request,
* so we now either ignore the request or respond
* with CHANNEL_FAILURE, depending on want_reply.
*/
if (want_reply) {
ssh2_pkt_init(SSH2_MSG_CHANNEL_FAILURE);
ssh2_pkt_adduint32(c->remoteid);
ssh2_pkt_send();
}
} else if (pktin.type == SSH2_MSG_CHANNEL_OPEN) { } else if (pktin.type == SSH2_MSG_CHANNEL_OPEN) {
char *type; char *type;
int typelen; int typelen;