From e558827c4e22b66e160c8f80c6d0c32719bfb155 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Tue, 4 Sep 2018 20:33:21 +0200 Subject: [PATCH] channels: Don't read from a closed channel Fixes T76 Signed-off-by: Andreas Schneider --- src/channels.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/channels.c b/src/channels.c index e19905b6..6548ddda 100644 --- a/src/channels.c +++ b/src/channels.c @@ -2726,7 +2726,12 @@ int ssh_channel_read_timeout(ssh_channel channel, if (rc == SSH_ERROR){ return rc; } - if (session->session_state == SSH_SESSION_STATE_ERROR){ + + /* + * If the channel is closed or in an error state, reading from it is an error + */ + if (session->session_state == SSH_SESSION_STATE_ERROR || + channel->state == SSH_CHANNEL_STATE_CLOSED) { return SSH_ERROR; } if (channel->remote_eof && ssh_buffer_get_len(stdbuf) == 0) {