diff options
author | Anderson Toshiyuki Sasaki <ansasaki@redhat.com> | 2018-12-03 17:27:08 +0100 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2018-12-07 17:44:46 +0100 |
commit | 8e69d435efb4193e474739674c32ec940c51ddd0 (patch) | |
tree | 9249fa0acb8424a3630941d47658a061cb357a79 | |
parent | d78a29eb792fd09c836dd5f5db7f29c1c449ec2a (diff) | |
download | libssh-8e69d435efb4193e474739674c32ec940c51ddd0.tar.gz libssh-8e69d435efb4193e474739674c32ec940c51ddd0.tar.xz libssh-8e69d435efb4193e474739674c32ec940c51ddd0.zip |
channels: Set error state when closed channel is read
When an attempt to read a closed channel happens, set the session error
state properly.
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
-rw-r--r-- | src/channels.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/channels.c b/src/channels.c index 0dfa946d..8875392a 100644 --- a/src/channels.c +++ b/src/channels.c @@ -2766,8 +2766,13 @@ int ssh_channel_read_timeout(ssh_channel channel, /* * 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) { + if (session->session_state == SSH_SESSION_STATE_ERROR) { + return SSH_ERROR; + } + 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) { |