From: ben Date: Sun, 24 Jul 2005 13:46:14 +0000 (+0000) Subject: draft-ietf-secsh-transport-24 says that only "SSH-" at the start of a line X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/putty/commitdiff_plain/8c1835c0f951be43da1fb19405c7ff958a9b8661?ds=sidebyside 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. git-svn-id: svn://svn.tartarus.org/sgt/putty@6138 cda61777-01e9-0310-a592-d414129be87e --- diff --git a/ssh.c b/ssh.c index a9bed27a..2b2b1dc5 100644 --- a/ssh.c +++ b/ssh.c @@ -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;