Subject: Re: libssh2_channel_write_ex returned more bytes than requested (buflen)

Re: libssh2_channel_write_ex returned more bytes than requested (buflen)

From: Matt Nowick <nowick_at_imonmail.com>
Date: Sat, 14 Sep 2013 09:54:24 -0500

Daniel,
I am using libssh2-1.4.3 compiled against openSSL instead of libgcrypt
(the Debian default).
The client machine (which indicated the error) is running Debian Linux
6.0.7, Linux kernel 2.6.32-5-686.
Unfortunately, the error happened after a series of communications
errors, so I'm not sure how I could duplicate it.

I don't know if it helps, but here are more log entries preceding the
crash.

The errors "Unable to send channel data" were generating using the
following libssh2 call:
libssh2_session_last_error(ssh_session, &errorMessage, NULL, 0);

[Wed Sep 11 07:59:22 2013] writeRawPacket: ssh channel is busy, trying
2nd time...
[Wed Sep 11 07:59:22 2013] writeRawPacket: ssh channel is busy, trying
3rd time...
[Wed Sep 11 07:59:23 2013] writeRawPacket: libssh2_channel_write_ex
failure: Unable to send channel data
[Wed Sep 11 07:59:23 2013] dio_packetRW: server1 error 'general
communications error' in mode SEND, errorCount=7
[Wed Sep 11 07:59:30 2013] writeRawPacket: ssh channel is busy, trying
2nd time...
[Wed Sep 11 07:59:31 2013] writeRawPacket: ssh channel is busy, trying
3rd time...
[Wed Sep 11 07:59:31 2013] writeRawPacket: libssh2_channel_write_ex
failure: Unable to send channel data
[Wed Sep 11 07:59:31 2013] dio_packetRW: server1 error 'general
communications error' in mode FLUSH, errorCount=8
[Wed Sep 11 07:59:41 2013] writeRawPacket: wrote 746/46 bytes to ssh
channel, trying 2nd time...

Its kind of like libssh2 continued to queue the data that it was unable
to send and then it sent it all at once.
These ssh channel is busy errors are not uncommon, but I've never seen
it crash like this before.

I don't think its related, but I've also been having problems with the
libssh2_channel_window_read returning a channel window
size that get smaller every time I read data from the channel. To fix
the bug, I watch the read window shrink and when it gets below 2K or so,
I close the channel and session and then renegotiate with the server.

Thanks for you help

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2013-09-14