1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-25 01:02:24 +00:00

Unconditionally fill the SSH-1 dispatch table.

In SSH-2, every possible packet type code has a non-NULL entry in the
dispatch table, even if most of them are just ssh2_msg_unimplemented.
In SSH-1, some dispatch table entries are NULL, which means that the
code processing the dispatch table has to have some SSH-1 specific
fallback logic.

Now I've put the fallback logic in a separate function, and replaced
the NULL table entries with pointers to that function, so that another
pointless difference between the SSH-1 and SSH-2 code is removed.
This commit is contained in:
Simon Tatham 2018-05-18 07:22:57 +01:00
parent 0ce92248a0
commit 0a15a2c471

16
ssh.c
View File

@ -6268,15 +6268,25 @@ static void ssh_msg_ignore(Ssh ssh, struct Packet *pktin)
/* Do nothing, because we're ignoring it! Duhh. */
}
static void ssh1_coro_wrapper(Ssh ssh, struct Packet *pktin)
{
if (!ssh->protocol_initial_phase_done) {
if (do_ssh1_login(ssh, NULL, 0, pktin))
ssh->protocol_initial_phase_done = TRUE;
} else {
do_ssh1_connection(ssh, NULL, 0, pktin);
}
}
static void ssh1_protocol_setup(Ssh ssh)
{
int i;
/*
* Most messages are handled by the coroutines.
* Most messages are handled by the main protocol routine.
*/
for (i = 0; i < 256; i++)
ssh->packet_dispatch[i] = NULL;
ssh->packet_dispatch[i] = ssh1_coro_wrapper;
/*
* These special message types we install handlers for.
@ -6293,7 +6303,7 @@ static void ssh1_protocol(Ssh ssh, const void *vin, int inlen,
if (ssh->state == SSH_STATE_CLOSED)
return;
if (pktin && ssh->packet_dispatch[pktin->type]) {
if (pktin) {
ssh->packet_dispatch[pktin->type](ssh, pktin);
return;
}