# HG changeset patch # User Matt Johnston # Date 1141460536 0 # Node ID 7f9adaf85fca7f07126b97a101e352c576c7239e # Parent 8438ff0cdb74bbb4afe441e90cc730d0be99e949 Exit with a message if the ssh protocol version is incompatible diff -r 8438ff0cdb74 -r 7f9adaf85fca common-session.c --- a/common-session.c Tue Feb 28 04:04:27 2006 +0000 +++ b/common-session.c Sat Mar 04 08:22:16 2006 +0000 @@ -232,10 +232,8 @@ 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 @@ 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)) }