Subject: [libssh2] #218: libssh2_session_startup fails with certain ssh servers

[libssh2] #218: libssh2_session_startup fails with certain ssh servers

From: libssh2 Trac <trac_at_libssh2.stuge.se>
Date: Thu, 05 May 2011 17:10:38 -0000

#218: libssh2_session_startup fails with certain ssh servers
---------------------+------------------------------------------------------
  Reporter: mstrsn | Owner:
      Type: defect | Status: new
  Priority: normal | Milestone: 1.2.9
 Component: SFTP | Version: 1.2.8
  Keywords: banner | Blocks:
Blocked By: |
---------------------+------------------------------------------------------
 Using libssh2_session_startup() with one particular ssh server always
 fails with LIBSSH2_ERROR_BANNER_RECV. Debugging the problem, I learned
 that my client program does not receive the complete banner from the
 server before blocking. This is a problem, because the loop in
 session_startup() that calls banner_receive() resets banner_TxRx_state to
 libssh2_NB_state_idle within the loop, causing the first portion of the
 banner to be lost when banner_receive() tries to get the rest of the
 banner. The fix that works for me is to update session.c like this:

 {{{
 #!diff
 --- session.c.orig Tue Apr 26 13:41:46 2011
 +++ session.c Tue Apr 26 14:59:06 2011
 @@ -657,12 +657,11 @@
                                    "Failed sending banner");
          }
          session->startup_state = libssh2_NB_state_sent;
 + session->banner_TxRx_state = libssh2_NB_state_idle;
      }

      if (session->startup_state == libssh2_NB_state_sent) {
          do {
 - session->banner_TxRx_state = libssh2_NB_state_idle;
 -
              rc = banner_receive(session);
              if (rc)
                  return _libssh2_error(session, rc,
 }}}

 I am using Solaris 10 x386 with gcc 3.4.6. The ssh server is running on a
 Ruggedcom switch running ROS 3.8.1. The banner returned by this server is
 "SSH-2.0-Mocana SSH".

-- 
Ticket URL: <http://trac.libssh2.org/ticket/218>
libssh2 <http://trac.libssh2.org/>
C library for writing portable SSH2 clients
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2011-05-05