From d972dc3e478f5958939754607a276aca65c6ce00 Mon Sep 17 00:00:00 2001 From: Anderson Toshiyuki Sasaki Date: Tue, 23 Jun 2020 16:36:21 +0200 Subject: [PATCH] Do not return error when the server properly closed the channel Resolves: #1849069 --- ...t-return-error-server-closed-channel.patch | 43 +++++++++++++++++++ libssh.spec | 6 ++- 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 libssh-0.9.4-do-not-return-error-server-closed-channel.patch diff --git a/libssh-0.9.4-do-not-return-error-server-closed-channel.patch b/libssh-0.9.4-do-not-return-error-server-closed-channel.patch new file mode 100644 index 0000000..387b9c0 --- /dev/null +++ b/libssh-0.9.4-do-not-return-error-server-closed-channel.patch @@ -0,0 +1,43 @@ +From 750e4f3f9d3ec879929801d65a500ec3ad84ff67 Mon Sep 17 00:00:00 2001 +From: Anderson Toshiyuki Sasaki +Date: Thu, 18 Jun 2020 19:08:54 +0200 +Subject: [PATCH] channel: Do not return error if the server closed the channel + +If the server properly closed the channel, the client should not return +error if it finds the channel closed. + +Fixes T231 + +Signed-off-by: Anderson Toshiyuki Sasaki +Reviewed-by: Jakub Jelen +--- + src/channels.c | 7 ++++--- + 1 file changed, 4 insertions(+), 3 deletions(-) + +diff --git a/src/channels.c b/src/channels.c +index 9fe309d0..607bd568 100644 +--- a/src/channels.c ++++ b/src/channels.c +@@ -2932,15 +2932,16 @@ int ssh_channel_read_timeout(ssh_channel channel, + if (session->session_state == SSH_SESSION_STATE_ERROR) { + return SSH_ERROR; + } ++ /* If the server closed the channel properly, there is nothing to do */ ++ if (channel->remote_eof && ssh_buffer_get_len(stdbuf) == 0) { ++ return 0; ++ } + if (channel->state == SSH_CHANNEL_STATE_CLOSED) { + ssh_set_error(session, + SSH_FATAL, + "Remote channel is closed."); + return SSH_ERROR; + } +- if (channel->remote_eof && ssh_buffer_get_len(stdbuf) == 0) { +- return 0; +- } + len = ssh_buffer_get_len(stdbuf); + /* Read count bytes if len is greater, everything otherwise */ + len = (len > count ? count : len); +-- +2.26.2 + diff --git a/libssh.spec b/libssh.spec index 8433546..17addfd 100644 --- a/libssh.spec +++ b/libssh.spec @@ -1,6 +1,6 @@ Name: libssh Version: 0.9.4 -Release: 2%{?dist} +Release: 3%{?dist} Summary: A library implementing the SSH protocol License: LGPLv2+ URL: http://www.libssh.org @@ -13,6 +13,7 @@ Source4: libssh_server.config Patch0: libssh-0.9.4-enable-sshd-sha1-algorithms.patch Patch1: libssh-0.9.4-fix-version.patch +Patch2: libssh-0.9.4-do-not-return-error-server-closed-channel.patch BuildRequires: cmake BuildRequires: gcc-c++ @@ -137,6 +138,9 @@ popd %attr(0644,root,root) %config(noreplace) %{_sysconfdir}/libssh/libssh_server.config %changelog +* Mon Jun 22 2020 Anderson Sasaki - 0.9.4-3 +- Do not return error when server properly closed the channel (#1849069) + * Wed Apr 15 2020 Anderson Sasaki - 0.9.4-2 - Added patch to fix returned version