channels: Bugfix for a possible invalid pointer usage (channel->session) in various places

BUG: https://red.libssh.org/issues/230

Signed-off-by: David Kedves <kedazo@severalnines.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
David Kedves
2016-03-24 15:46:23 +01:00
committed by Andreas Schneider
parent ffe8b98cc2
commit d7df4429eb

View File

@@ -1245,7 +1245,7 @@ static int channel_write_common(ssh_channel channel,
return -1;
}
if (channel->session->session_state == SSH_SESSION_STATE_ERROR) {
if (session->session_state == SSH_SESSION_STATE_ERROR) {
return SSH_ERROR;
}
#ifdef WITH_SSH1
@@ -1276,7 +1276,7 @@ static int channel_write_common(ssh_channel channel,
ssh_channel_waitwindow_termination,channel);
if (rc == SSH_ERROR ||
!ssh_channel_waitwindow_termination(channel) ||
channel->session->session_state == SSH_SESSION_STATE_ERROR ||
session->session_state == SSH_SESSION_STATE_ERROR ||
channel->state == SSH_CHANNEL_STATE_CLOSED)
goto out;
continue;
@@ -2708,7 +2708,7 @@ int ssh_channel_read_timeout(ssh_channel channel,
if (rc == SSH_ERROR){
return rc;
}
if (channel->session->session_state == SSH_SESSION_STATE_ERROR){
if (session->session_state == SSH_SESSION_STATE_ERROR){
return SSH_ERROR;
}
if (channel->remote_eof && ssh_buffer_get_len(stdbuf) == 0) {
@@ -2773,7 +2773,7 @@ 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) {
if (channel->session->session_state == SSH_SESSION_STATE_ERROR){
if (session->session_state == SSH_SESSION_STATE_ERROR){
return SSH_ERROR;
}