session BUGFIX freeing invalid multi-channel SSH sessions
Fixes cesnet/netopeer2#518
diff --git a/src/session_server_ssh.c b/src/session_server_ssh.c
index 3069ae6..899f8b3 100644
--- a/src/session_server_ssh.c
+++ b/src/session_server_ssh.c
@@ -1130,11 +1130,11 @@
}
VRB("Received an SSH message \"%s\" of subtype \"%s\".", str_type, str_subtype);
- if ((session->status == NC_STATUS_CLOSING) || (session->status == NC_STATUS_INVALID)) {
+ if (!session || (session->status == NC_STATUS_CLOSING) || (session->status == NC_STATUS_INVALID)) {
/* "valid" situation if, for example, receiving some auth or channel request timeouted,
* but we got it now, during session free */
VRB("SSH message arrived on a %s session, the request will be denied.",
- (session->status == NC_STATUS_CLOSING ? "closing" : "invalid"));
+ (session && session->status == NC_STATUS_CLOSING ? "closing" : "invalid"));
ssh_message_reply_default(msg);
return 0;
}