Blame SOURCES/libssh-0.9.4-do-not-return-error-server-closed-channel.patch

f3993f
From 750e4f3f9d3ec879929801d65a500ec3ad84ff67 Mon Sep 17 00:00:00 2001
f3993f
From: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
f3993f
Date: Thu, 18 Jun 2020 19:08:54 +0200
f3993f
Subject: [PATCH] channel: Do not return error if the server closed the channel
f3993f
f3993f
If the server properly closed the channel, the client should not return
f3993f
error if it finds the channel closed.
f3993f
f3993f
Fixes T231
f3993f
f3993f
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
f3993f
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
f3993f
---
f3993f
 src/channels.c | 7 ++++---
f3993f
 1 file changed, 4 insertions(+), 3 deletions(-)
f3993f
f3993f
diff --git a/src/channels.c b/src/channels.c
f3993f
index 9fe309d0..607bd568 100644
f3993f
--- a/src/channels.c
f3993f
+++ b/src/channels.c
f3993f
@@ -2932,15 +2932,16 @@ int ssh_channel_read_timeout(ssh_channel channel,
f3993f
   if (session->session_state == SSH_SESSION_STATE_ERROR) {
f3993f
       return SSH_ERROR;
f3993f
   }
f3993f
+  /* If the server closed the channel properly, there is nothing to do */
f3993f
+  if (channel->remote_eof && ssh_buffer_get_len(stdbuf) == 0) {
f3993f
+      return 0;
f3993f
+  }
f3993f
   if (channel->state == SSH_CHANNEL_STATE_CLOSED) {
f3993f
       ssh_set_error(session,
f3993f
                     SSH_FATAL,
f3993f
                     "Remote channel is closed.");
f3993f
       return SSH_ERROR;
f3993f
   }
f3993f
-  if (channel->remote_eof && ssh_buffer_get_len(stdbuf) == 0) {
f3993f
-    return 0;
f3993f
-  }
f3993f
   len = ssh_buffer_get_len(stdbuf);
f3993f
   /* Read count bytes if len is greater, everything otherwise */
f3993f
   len = (len > count ? count : len);
f3993f
-- 
f3993f
2.26.2
f3993f