From 88366b5ec26c1ac16981e81201cabfb3a6bff8b1 Mon Sep 17 00:00:00 2001 From: Alexander Lamaison Date: Thu, 28 Nov 2013 23:36:08 +0000 Subject: [PATCH] Fix missing `_libssh2_error` in `_libssh2_channel_write`. In one case, the error code from `_libssh2_transport_read` was being returned from `_libssh2_channel_write` without setting it as the last error by calling `_libssh2_error`. This commit fixes that. Found when using a session whose socket had been inadvertently destroyed. The calling code got confused because via `libssh2_session_last_error` it appeared no error had occurred, despite one being returned from the previous function. --- src/channel.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/channel.c b/src/channel.c index d6bfb98..9979522 100644 --- a/src/channel.c +++ b/src/channel.c @@ -2023,8 +2023,10 @@ _libssh2_channel_write(LIBSSH2_CHANNEL *channel, int stream_id, rc = _libssh2_transport_read(session); while (rc > 0); - if((rc < 0) && (rc != LIBSSH2_ERROR_EAGAIN)) - return rc; + if((rc < 0) && (rc != LIBSSH2_ERROR_EAGAIN)) { + return _libssh2_error(channel->session, rc, + "Failure while draining incoming flow"); + } if(channel->local.window_size <= 0) { /* there's no room for data so we stop */