diff options
author | Matt Johnston <matt@ucc.asn.au> | 2006-03-04 08:22:16 +0000 |
---|---|---|
committer | Matt Johnston <matt@ucc.asn.au> | 2006-03-04 08:22:16 +0000 |
commit | b5989964979e3ee885eeb6d0758d96605b131a7b (patch) | |
tree | 2bf1047ae8bb1c1aab8ce8daba01051a1d2ca3d7 /common-session.c | |
parent | a5a56874afe1ba8fd393dee90fb141d5f731d867 (diff) |
Exit with a message if the ssh protocol version is incompatible
--HG--
extra : convert_revision : 5d396842815593611f0d61762440145d1fc74d5a
Diffstat (limited to 'common-session.c')
-rw-r--r-- | common-session.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/common-session.c b/common-session.c index e8dc650..4c15391 100644 --- a/common-session.c +++ b/common-session.c @@ -232,10 +232,8 @@ void session_identification() { dropbear_exit("Error writing ident string"); } - /* We allow up to 9 lines before the actual version string, to - * account for wrappers/cruft etc. According to the spec only the client - * needs to handle this, but no harm in letting the server handle it too */ - for (i = 0; i < 10; i++) { + /* If they send more than 50 lines, something is wrong */ + for (i = 0; i < 50; i++) { len = ident_readln(ses.sock, linebuf, sizeof(linebuf)); if (len < 0 && errno != EINTR) { @@ -259,6 +257,12 @@ void session_identification() { memcpy(ses.remoteident, linebuf, len); } + /* Shall assume that 2.x will be backwards compatible. */ + if (strncmp(ses.remoteident, "SSH-2.", 6) != 0 + && strncmp(ses.remoteident, "SSH-1.99-", 9) != 0) { + dropbear_exit("Incompatible remote version '%s'", ses.remoteident); + } + TRACE(("remoteident: %s", ses.remoteident)) } |