www.libssh2.org | Daily snapshots | Mailing list archive | Docs | Examples | github

Archive Index This month's Index

Subject: [libssh2] #245: libssh2 does not handle channel_close correctly

[libssh2] #245: libssh2 does not handle channel_close correctly

From: libssh2 Trac <trac_at_libssh2.stuge.se>
Date: Tue, 10 Jul 2012 16:15:58 -0000

#245: libssh2 does not handle channel_close correctly
----------------------+--------------------
 Reporter: maxmtl | Owner:
     Type: defect | Status: new
 Priority: normal | Milestone: 1.4.0
Component: protocol | Version: 1.4.1
 Keywords: | Blocked By:
   Blocks: |
----------------------+--------------------
 libssh2 does not wait for the CHANNEL_CLOSE message from the server before
 closing the socket. It closes the socket as soon as any message has been
 received (e.g. CHANNEL_EOF or CHANNEL_REQUEST).

 The problem has been seen with libssh2 example sftp_write.c when
 communicating with the Apache Mina sshd server. Some exceptions about
 Connection Reset were displayed. The problem was not present using either
 the OpenSsh client or server applications.

 The attached patch corrects the problem; in channel.c / _channel_close(),
 _libssh2_transport_read is used to wait for the CHANNEL_CLOSE message. Its
 return value is validated using !rc, however when a message is received
 the return value is set to the actual message type, so (rc >= 0) should be
 used instead of (!rc).

 It may be related to issues 236 and 239, since some messages may not be
 parsed (CHANNEL_REQUEST:exit_status, for example).

 Tested with version 1.4.2; however this value was not available in the
 choices...

 (Debugging done under contract for Accedian Networks)

-- 
Ticket URL: <http://trac.libssh2.org/ticket/245>
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 2012-07-10

the libssh2 team