From 19f2abd166528b8540abb9f56008eb0f2c589959 Mon Sep 17 00:00:00 2001 From: Brendan Shanks Date: Sun, 4 Nov 2018 22:16:39 -0800 Subject: [PATCH] Add more NULL checking/error handling --- macssh/source/ssh/ssh2.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/macssh/source/ssh/ssh2.c b/macssh/source/ssh/ssh2.c index a10a1c7..8e08f36 100755 --- a/macssh/source/ssh/ssh2.c +++ b/macssh/source/ssh/ssh2.c @@ -1665,12 +1665,18 @@ void *ssh2_thread(WindRec*w) { LIBSSH2_SESSION *session = libssh2_session_init_ex(NULL, NULL, NULL, w); + if (!session) { + syslog(0, "libssh2_session_init_ex() failed\n"); + goto closesocket; + } + if (w->trace) libssh2_trace(session, INT_MAX); libssh2_trace_sethandler(session, NULL, libssh2_handler); if (libssh2_session_startup(session, sock)) { syslog(0, "Failure establishing SSH session\n"); + goto closesession; } if (!ssh2_hostkey_approved(session, hostname, w->portNum))