mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-11 18:50:28 +09:00
Fix: NULL pointer check in ssh_channel_is_closed
The ssh_channel_is_closed function would crash when accessing channel->session->alive if session is NULL. This patch adds a null check before accessing the session pointer. - build succeeded - unit test passed - no new unit test added https://gitlab.com/libssh/libssh-mirror/-/issues/239 Signed-off-by: Raviraaja Lakshmanan <mailstoraviraaja@gmail.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
This commit is contained in:
@@ -1728,7 +1728,7 @@ int ssh_channel_is_open(ssh_channel channel)
|
|||||||
*/
|
*/
|
||||||
int ssh_channel_is_closed(ssh_channel channel)
|
int ssh_channel_is_closed(ssh_channel channel)
|
||||||
{
|
{
|
||||||
if (channel == NULL) {
|
if (channel == NULL || channel->session == NULL) {
|
||||||
return SSH_ERROR;
|
return SSH_ERROR;
|
||||||
}
|
}
|
||||||
return (channel->state != SSH_CHANNEL_STATE_OPEN || channel->session->alive == 0);
|
return (channel->state != SSH_CHANNEL_STATE_OPEN || channel->session->alive == 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user