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

Stop using ssh->protocol_initial_phase_done in SSH-1.

This flag was used to indicate that ssh1_protocol (or, as of the
previous commit, ssh1_coro_wrapper) should stop passing packets to
do_ssh1_login and start passing them to do_ssh1_connection.

Now, instead of using a flag, we simply have two separate versions of
ssh1_coro_wrapper for the two phases, and indicate the change by
rewriting all the entries in the dispatch table. So now we _just_ have
a function-pointer dereference per packet, rather than one of those
and then a flag check.
This commit is contained in:
Simon Tatham 2018-05-18 07:22:57 +01:00
parent 5d9adc5c93
commit bf62c85051

23
ssh.c
View File

@ -973,7 +973,7 @@ struct ssh_tag {
struct rdpkt2_state_tag rdpkt2_state; struct rdpkt2_state_tag rdpkt2_state;
struct rdpkt2_bare_state_tag rdpkt2_bare_state; struct rdpkt2_bare_state_tag rdpkt2_bare_state;
/* SSH-1 and SSH-2 use this for different things, but both use it */ /* Only used by SSH-2 */
int protocol_initial_phase_done; int protocol_initial_phase_done;
void (*protocol) (Ssh ssh, const void *vin, int inlen); void (*protocol) (Ssh ssh, const void *vin, int inlen);
@ -6268,16 +6268,23 @@ static void ssh_msg_ignore(Ssh ssh, struct Packet *pktin)
/* Do nothing, because we're ignoring it! Duhh. */ /* Do nothing, because we're ignoring it! Duhh. */
} }
static void ssh1_coro_wrapper(Ssh ssh, struct Packet *pktin) static void ssh1_coro_wrapper_session(Ssh ssh, struct Packet *pktin);
static void ssh1_coro_wrapper_initial(Ssh ssh, struct Packet *pktin)
{ {
if (!ssh->protocol_initial_phase_done) { if (do_ssh1_login(ssh, NULL, 0, pktin)) {
if (do_ssh1_login(ssh, NULL, 0, pktin)) int i;
ssh->protocol_initial_phase_done = TRUE; for (i = 0; i < 256; i++)
} else { if (ssh->packet_dispatch[i] == ssh1_coro_wrapper_initial)
do_ssh1_connection(ssh, NULL, 0, pktin); ssh->packet_dispatch[i] = ssh1_coro_wrapper_session;
} }
} }
static void ssh1_coro_wrapper_session(Ssh ssh, struct Packet *pktin)
{
do_ssh1_connection(ssh, NULL, 0, pktin);
}
static void ssh1_protocol_setup(Ssh ssh) static void ssh1_protocol_setup(Ssh ssh)
{ {
int i; int i;
@ -6286,7 +6293,7 @@ static void ssh1_protocol_setup(Ssh ssh)
* Most messages are handled by the main protocol routine. * Most messages are handled by the main protocol routine.
*/ */
for (i = 0; i < 256; i++) for (i = 0; i < 256; i++)
ssh->packet_dispatch[i] = ssh1_coro_wrapper; ssh->packet_dispatch[i] = ssh1_coro_wrapper_initial;
/* /*
* These special message types we install handlers for. * These special message types we install handlers for.