diff options
author | Andreas Schneider <asn@cryptomilk.org> | 2018-09-04 20:33:21 +0200 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2018-09-04 20:34:52 +0200 |
commit | e558827c4e22b66e160c8f80c6d0c32719bfb155 (patch) | |
tree | 672bb10d35662225eaf511bc8ed687de936b5848 /src/channels.c | |
parent | 1e195a232ad7c9d43042b78361469664e81e3495 (diff) | |
download | libssh-e558827c4e22b66e160c8f80c6d0c32719bfb155.tar.gz libssh-e558827c4e22b66e160c8f80c6d0c32719bfb155.tar.xz libssh-e558827c4e22b66e160c8f80c6d0c32719bfb155.zip |
channels: Don't read from a closed channel
Fixes T76
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Diffstat (limited to 'src/channels.c')
-rw-r--r-- | src/channels.c | 7 |
1 files changed, 6 insertions, 1 deletions
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) { |