[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Quick question about some patches


On Friday, April 08, 2016 11:12:36 AM Kenneth Reister wrote:
> I and a colleague submitted some patches.  I was able to find his in the
> commit logs.  One in the 0.7.3 branch and the other 2 in master.  I could
> not find mine at all (see
> http://www.libssh.org/archive/libssh/2015-11/0000000.html)
> 
> What can I do to make sure that my patch gets committed?
> Do you have an estimate of when a release of the master branch will be
> forthcoming?

Hello!

I've had it on my todo list but time didn't permit to work on libssh. Sorry!

Your Signed-off: is missing. I've added it to the patch and then reformatted 
the function. Please check if the attached patch is fine with you!

Best regards,


	-- andreas
From 6329a012301bb031a9b00ad5a14f49a0d3166d59 Mon Sep 17 00:00:00 2001
From: Ken Reister <reister.kenneth@xxxxxxxxxx>
Date: Wed, 14 Oct 2015 15:50:49 -0500
Subject: [PATCH 1/2] 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 <reister.kenneth@xxxxxxxxxx>
Reviewed-by: Andreas Schneider <asn@xxxxxxxxxxxxxx>
---
 src/client.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/client.c b/src/client.c
index 0cca110..c389d79 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 */
-- 
2.5.5


From a734bfae8d86f5387dfb1847773046263bed1c45 Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn@xxxxxxxxxxxxxx>
Date: Mon, 2 May 2016 09:06:51 +0200
Subject: [PATCH 2/2] client: Reformat callback_receive_banner()

The function is hard to read as the indentation is not correctly
applied.

Signed-off-by: Andreas Schneider <asn@xxxxxxxxxxxxxx>
---
 src/client.c | 111 +++++++++++++++++++++++++++++++++--------------------------
 1 file changed, 62 insertions(+), 49 deletions(-)

diff --git a/src/client.c b/src/client.c
index c389d79..918c8b9 100644
--- a/src/client.c
+++ b/src/client.c
@@ -90,59 +90,72 @@ static void socket_callback_connected(int code, int errno_code, void *user){
  * @param  user is a pointer to session
  * @returns Number of bytes processed, or zero if the banner is not complete.
  */
-static int callback_receive_banner(const void *data, size_t len, void *user) {
-  char *buffer = (char *)data;
-  ssh_session session=(ssh_session) user;
-  char *str = NULL;
-  size_t i;
-  int ret=0;
-
-  if(session->session_state != SSH_SESSION_STATE_SOCKET_CONNECTED){
-  	ssh_set_error(session,SSH_FATAL,"Wrong state in callback_receive_banner : %d",session->session_state);
-
-  	return SSH_ERROR;
-  }
-  for(i=0;i<len;++i){
+static int callback_receive_banner(const void *data, size_t len, void *user)
+{
+    char *buffer = (char *)data;
+    ssh_session session=(ssh_session) user;
+    char *str = NULL;
+    size_t i;
+    int ret=0;
+
+    if (session->session_state != SSH_SESSION_STATE_SOCKET_CONNECTED) {
+        ssh_set_error(session,SSH_FATAL,
+                      "Wrong state in callback_receive_banner : %d",
+                      session->session_state);
+
+        return SSH_ERROR;
+    }
+    for (i = 0; i < len; ++i) {
 #ifdef WITH_PCAP
-  	if(session->pcap_ctx && buffer[i] == '\n'){
-  		ssh_pcap_context_write(session->pcap_ctx,SSH_PCAP_DIR_IN,buffer,i+1,i+1);
-  	}
+        if (session->pcap_ctx && buffer[i] == '\n') {
+            ssh_pcap_context_write(session->pcap_ctx,
+                                   SSH_PCAP_DIR_IN,
+                                   buffer,i+1,
+                                   i+1);
+        }
 #endif
-    if(buffer[i]=='\r') {
-        buffer[i]='\0';
-    }
-    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;
+        if (buffer[i] == '\r') {
+            buffer[i] = '\0';
         }
-        /* number of bytes read */
-        ret = i + 1;
-        session->serverbanner = str;
-  		session->session_state=SSH_SESSION_STATE_BANNER_RECEIVED;
-  		SSH_LOG(SSH_LOG_PACKET,"Received banner: %s",str);
-		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 */
-  		session->session_state=SSH_SESSION_STATE_ERROR;
-  		ssh_set_error(session,SSH_FATAL,"Receiving banner: too large banner");
-
-  		return 0;
-  	}
-  }
+        if (buffer[i] == '\n') {
+            buffer[i] = '\0';
+            int cmp;
+
+            /* The server MAY send other lines of data... */
+            cmp = strncmp(buffer, "SSH-", 4);
+            if (cmp == 0) {
+                str = strdup(buffer);
+                if (str == NULL) {
+                    return SSH_ERROR;
+                }
+                /* number of bytes read */
+                ret = i + 1;
+                session->serverbanner = str;
+                session->session_state = SSH_SESSION_STATE_BANNER_RECEIVED;
+                SSH_LOG(SSH_LOG_PACKET, "Received banner: %s", str);
+                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 */
+            session->session_state=SSH_SESSION_STATE_ERROR;
+            ssh_set_error(session,
+                          SSH_FATAL,
+                          "Receiving banner: too large banner");
+
+            return 0;
+        }
+    }
 
-  return ret;
+    return ret;
 }
 
 /** @internal
-- 
2.5.5


Follow-Ups:
Re: Quick question about some patchesKenneth Reister <reister.kenneth@xxxxxxxxxx>
Archive administrator: postmaster@lists.cynapses.org