From c3ce3d5cc347367aa9f3735aa957695973072702 Mon Sep 17 00:00:00 2001 From: Ken Reister Date: Wed, 14 Oct 2015 15:50:49 -0500 Subject: [PATCH] client: Receive the banner correctly Comply with RFC 4253 compliance section 4.2. Allow data other than "SSH-" to be sent across prior to the actual version striong. Signed-off-by: Ken Reister Reviewed-by: Andreas Schneider --- src/client.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/client.c b/src/client.c index 2b78add0..d80ff869 100644 --- a/src/client.c +++ b/src/client.c @@ -113,6 +113,8 @@ static int callback_receive_banner(const void *data, size_t len, void *user) { } if (buffer[i]=='\n') { buffer[i] = '\0'; + /* The server MAY send other lines of data... */ + if (strncmp(buffer, "SSH-", 4) == 0) { str = strdup(buffer); if (str == NULL) { return SSH_ERROR; @@ -125,6 +127,11 @@ static int callback_receive_banner(const void *data, size_t len, void *user) { session->ssh_connection_callback(session); return ret; + } else { + SSH_LOG(SSH_LOG_DEBUG, "ssh_protocol_version_exchange: %s", buffer); + ret = i + 1; + break; + } } if(i>127){ /* Too big banner */