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

draft-ietf-secsh-transport-24 says that only "SSH-" at the start of a line

marks a version string.  It's a bit vague about the definition of a line,
but I think it's reasonable to assume that they'll end with LF.  Change
do_ssh_init() to ignore "SSH-" anywhere else.  This makes the existing state
machine overkill, so replace it with something a little more readable.

[originally from svn r6138]
This commit is contained in:
Ben Harris 2005-07-24 13:46:14 +00:00
parent d4a365000e
commit ae64be506f

31
ssh.c
View File

@ -2295,23 +2295,20 @@ static int do_ssh_init(Ssh ssh, unsigned char c)
crBegin(ssh->do_ssh_init_crstate); crBegin(ssh->do_ssh_init_crstate);
/* Search for the string "SSH-" in the input. */ /* Search for a line beginning with the string "SSH-" in the input. */
s->i = 0; for (;;) {
while (1) { if (c != 'S') goto no;
static const int transS[] = { 1, 2, 2, 1 }; crReturn(1);
static const int transH[] = { 0, 0, 3, 0 }; if (c != 'S') goto no;
static const int transminus[] = { 0, 0, 0, -1 }; crReturn(1);
if (c == 'S') if (c != 'H') goto no;
s->i = transS[s->i]; crReturn(1);
else if (c == 'H') if (c != '-') goto no;
s->i = transH[s->i]; break;
else if (c == '-') no:
s->i = transminus[s->i]; while (c != '\012')
else crReturn(1);
s->i = 0; crReturn(1);
if (s->i < 0)
break;
crReturn(1); /* get another character */
} }
s->vstrsize = 16; s->vstrsize = 16;