summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/channels.c21
-rw-r--r--tests/client/CMakeLists.txt1
2 files changed, 19 insertions, 3 deletions
diff --git a/src/channels.c b/src/channels.c
index b51ff57..6e9b2eb 100644
--- a/src/channels.c
+++ b/src/channels.c
@@ -1270,7 +1270,10 @@ int channel_write_common(ssh_channel channel, const void *data,
leave_function();
return -1;
}
-
+ if (channel->session->session_state == SSH_SESSION_STATE_ERROR){
+ leave_function();
+ return SSH_ERROR;
+ }
#ifdef WITH_SSH1
if (channel->version == 1) {
rc = channel_write1(channel, data, len);
@@ -2690,6 +2693,10 @@ int ssh_channel_read(ssh_channel channel, void *dest, uint32_t count, int is_std
leave_function();
return rc;
}
+ if (channel->session->session_state == SSH_SESSION_STATE_ERROR){
+ leave_function();
+ return SSH_ERROR;
+ }
if (channel->remote_eof && buffer_get_rest_len(stdbuf) == 0) {
leave_function();
return 0;
@@ -2753,8 +2760,12 @@ int ssh_channel_read_nonblocking(ssh_channel channel, void *dest, uint32_t count
to_read = ssh_channel_poll(channel, is_stderr);
if (to_read <= 0) {
- leave_function();
- return to_read; /* may be an error code */
+ if (channel->session->session_state == SSH_SESSION_STATE_ERROR){
+ leave_function();
+ return SSH_ERROR;
+ }
+ leave_function();
+ return to_read; /* may be an error code */
}
if (to_read > (int)count) {
@@ -2799,6 +2810,10 @@ int ssh_channel_poll(ssh_channel channel, int is_stderr){
}
if (buffer_get_rest_len(stdbuf) == 0 && channel->remote_eof == 0) {
+ if (channel->session->session_state == SSH_SESSION_STATE_ERROR){
+ leave_function();
+ return SSH_ERROR;
+ }
if (ssh_handle_packets(channel->session, SSH_TIMEOUT_NONBLOCKING)==SSH_ERROR) {
leave_function();
return SSH_ERROR;
diff --git a/tests/client/CMakeLists.txt b/tests/client/CMakeLists.txt
index d8a5860..e3bb45d 100644
--- a/tests/client/CMakeLists.txt
+++ b/tests/client/CMakeLists.txt
@@ -5,6 +5,7 @@ add_cmocka_test(torture_auth torture_auth.c ${TORTURE_LIBRARY})
add_cmocka_test(torture_connect torture_connect.c ${TORTURE_LIBRARY})
add_cmocka_test(torture_knownhosts torture_knownhosts.c ${TORTURE_LIBRARY})
add_cmocka_test(torture_proxycommand torture_proxycommand.c ${TORTURE_LIBRARY})
+add_cmocka_test(torture_session torture_session.c ${TORTURE_LIBRARY})
if (WITH_SFTP)
add_cmocka_test(torture_sftp_static torture_sftp_static.c ${TORTURE_LIBRARY})
add_cmocka_test(torture_sftp_dir torture_sftp_dir.c ${TORTURE_LIBRARY})