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

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