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

We shouldn't offer the Break special when we don't have a session to send it

down. (A side effect of fixing this is that ssh->mainchain is set to NULL
when it closes, which might avoid other sorts of trouble.)

While we're here, don't bother offering SSH1_MSG_IGNORE if we believe the
remote will barf on it.

[originally from svn r4650]
This commit is contained in:
Jacob Nevins 2004-10-17 15:32:42 +00:00
parent 4482a79162
commit 1efa60e40d

55
ssh.c
View File

@ -5646,6 +5646,7 @@ static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen, int ispkt)
ssh->mainchan->v.v2.remmaxpkt = ssh_pkt_getuint32(ssh); ssh->mainchan->v.v2.remmaxpkt = ssh_pkt_getuint32(ssh);
bufchain_init(&ssh->mainchan->v.v2.outbuffer); bufchain_init(&ssh->mainchan->v.v2.outbuffer);
add234(ssh->channels, ssh->mainchan); add234(ssh->channels, ssh->mainchan);
update_specials_menu(ssh->frontend);
logevent("Opened channel for session"); logevent("Opened channel for session");
} else } else
ssh->mainchan = NULL; ssh->mainchan = NULL;
@ -6227,7 +6228,9 @@ static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen, int ispkt)
/* Do pre-close processing on the channel. */ /* Do pre-close processing on the channel. */
switch (c->type) { switch (c->type) {
case CHAN_MAINSESSION: case CHAN_MAINSESSION:
break; /* nothing to see here, move along */ ssh->mainchan = NULL;
update_specials_menu(ssh->frontend);
break;
case CHAN_X11: case CHAN_X11:
if (c->u.x11.s != NULL) if (c->u.x11.s != NULL)
x11_close(c->u.x11.s); x11_close(c->u.x11.s);
@ -6878,24 +6881,50 @@ static void ssh_size(void *handle, int width, int height)
*/ */
static const struct telnet_special *ssh_get_specials(void *handle) static const struct telnet_special *ssh_get_specials(void *handle)
{ {
static const struct telnet_special ignore_special[] = {
{"IGNORE message", TS_NOP},
};
static const struct telnet_special ssh2_session_specials[] = {
{"", 0},
{"Break", TS_BRK}
/* XXX we should also support signals */
};
static const struct telnet_special specials_end[] = {
{NULL, 0}
};
static struct telnet_special ssh_specials[lenof(ignore_special) +
lenof(ssh2_session_specials) +
lenof(specials_end)];
Ssh ssh = (Ssh) handle; Ssh ssh = (Ssh) handle;
int i = 0;
#define ADD_SPECIALS(name) \
do { \
assert((i + lenof(name)) <= lenof(ssh_specials)); \
memcpy(&ssh_specials[i], name, sizeof name); \
i += lenof(name); \
} while(0)
if (ssh->version == 1) { if (ssh->version == 1) {
static const struct telnet_special ssh1_specials[] = { /* Don't bother offering IGNORE if we've decided the remote
{"IGNORE message", TS_NOP}, * won't cope with it, since we wouldn't bother sending it if
{NULL, 0} * asked anyway. */
}; if (!(ssh->remote_bugs & BUG_CHOKES_ON_SSH1_IGNORE))
return ssh1_specials; ADD_SPECIALS(ignore_special);
} else if (ssh->version == 2) { } else if (ssh->version == 2) {
static const struct telnet_special ssh2_specials[] = { /* XXX add rekey, when implemented */
{"Break", TS_BRK}, ADD_SPECIALS(ignore_special);
{"IGNORE message", TS_NOP}, if (ssh->mainchan)
{NULL, 0} ADD_SPECIALS(ssh2_session_specials);
}; } /* else we're not ready yet */
return ssh2_specials;
} else if (i) {
ADD_SPECIALS(specials_end);
return ssh_specials;
} else {
return NULL; return NULL;
} }
#undef ADD_SPECIALS
}
/* /*
* Send Telnet special codes. TS_EOF is useful for `plink', so you * Send Telnet special codes. TS_EOF is useful for `plink', so you