1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-10 01:48:00 +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);
/* Search for the string "SSH-" in the input. */
s->i = 0;
while (1) {
static const int transS[] = { 1, 2, 2, 1 };
static const int transH[] = { 0, 0, 3, 0 };
static const int transminus[] = { 0, 0, 0, -1 };
if (c == 'S')
s->i = transS[s->i];
else if (c == 'H')
s->i = transH[s->i];
else if (c == '-')
s->i = transminus[s->i];
else
s->i = 0;
if (s->i < 0)
break;
crReturn(1); /* get another character */
/* Search for a line beginning with the string "SSH-" in the input. */
for (;;) {
if (c != 'S') goto no;
crReturn(1);
if (c != 'S') goto no;
crReturn(1);
if (c != 'H') goto no;
crReturn(1);
if (c != '-') goto no;
break;
no:
while (c != '\012')
crReturn(1);
crReturn(1);
}
s->vstrsize = 16;