Fix crash when multiple windows are open and a window is closed

Fix crash when multiple windows are open and a window is closed. libssh2_exit() was
being called, de-init'ing mbed TLS. libssh2_init/exit() are now called at application launch/quit.
This commit is contained in:
Brendan Shanks 2018-06-27 23:31:39 -07:00
parent bf9958a273
commit 894a25dddf
5 changed files with 42 additions and 5 deletions

View File

@ -44,6 +44,7 @@
#include "telneterrors.h"
#include "wdefpatch.proto.h" //for wdefLoad
#include "memory.proto.h"
#include "sshglue.proto.h"
#include "AddressXLation.h"
#include <KeyChain.h>
@ -491,6 +492,7 @@ void init(void)
loadErrors(); //ditto for the error code
ssh2_init();
ssh_glue_initialize();
gInitialized = true;
}

View File

@ -40,6 +40,7 @@
#include "IConfig.proto.h"
#include "ae.proto.h"
#include "prefs.proto.h"
#include "sshglue.proto.h"
#include "Appearance.h"
//#define PROFILER // Define to use MW profiler
@ -174,6 +175,7 @@ void quit( void)
close_mb_files(); /* BYU - Don't leave any files open! */
stopInternetConfig();
ssh_glue_exit();
TelInfo->done = 1; /* BYU */
}

View File

@ -118,6 +118,8 @@ void make_env( lshcontext *context, WindRec *w );
int cvs_listen( int port );
void *ssh2_thread(WindRec*w);
void ssh_library_initialize(void);
void ssh_library_exit(void);
void ssh_protocol_initial(WindRec*w);
void ssh_packet_read(struct WindRec*w, unsigned char*databuf, short datalen);
void ssh_protocol_write(struct WindRec*w, unsigned char*databuf, short datalen);
@ -1734,10 +1736,8 @@ void *ssh2_thread(WindRec*w)
{
char hostname[256];
int sock;
int rc = libssh2_init(0);
syslog(0, "libssh2 init %d\n", rc);
sock = socket(AF_INET, SOCK_STREAM, 0);
int rc;
int sock = socket(AF_INET, SOCK_STREAM, 0);
fcntl(sock, F_SETFL, 0);
{
@ -1908,7 +1908,6 @@ closesession:
closesocket:
close(sock);
libssh2_exit();
}
done:
@ -2047,6 +2046,21 @@ done:
#endif
}
/*
* ssh_library_initialize
*/
void ssh_library_initialize(void)
{
libssh2_init(0);
}
/*
* ssh_library_exit
*/
void ssh_library_exit(void)
{
libssh2_exit();
}
/*
* ssh_protocol_initial

View File

@ -16,6 +16,8 @@
// prototypes for glued functions
#ifdef WE_HAVE_SSH
void ssh_library_initialize(void);
void ssh_library_exit(void);
void ssh_protocol_initial(WindRec*);
void ssh_packet_read(struct WindRec*, unsigned char*, short);
void ssh_protocol_write(struct WindRec*, unsigned char*, short);
@ -25,6 +27,20 @@ void ssh_exportkey(void);
void ssh_wresize(struct WindRec*);
#endif
void ssh_glue_initialize(void)
{
#ifdef WE_HAVE_SSH
ssh_library_initialize();
#endif
}
void ssh_glue_exit(void)
{
#ifdef WE_HAVE_SSH
ssh_library_exit();
#endif
}
void ssh_glue_initial(WindRec* tw)
{
#ifdef WE_HAVE_SSH

View File

@ -1,3 +1,6 @@
void ssh_glue_initialize(void);
void ssh_glue_exit(void);
void ssh_glue_initial(WindRec*);
short ssh_glue_installed(void);
void ssh_glue_write(struct WindRec*, unsigned char*, short);