changeset 1041:3fb883a6aa81

Some additional cleanup functions
author Matt Johnston <matt@ucc.asn.au>
date Tue, 24 Feb 2015 22:17:04 +0800
parents 2b4fd440399d
children 9699b9438ad9
files common-session.c svr-session.c
diffstat 2 files changed, 14 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/common-session.c	Tue Feb 24 22:01:33 2015 +0800
+++ b/common-session.c	Tue Feb 24 22:17:04 2015 +0800
@@ -260,13 +260,16 @@
 		return;
 	}
 
+	/* Beware of changing order of functions here. */
+
+	/* Must be before extra_session_cleanup() */
+	chancleanup();
+
 	if (ses.extra_session_cleanup) {
 		ses.extra_session_cleanup();
 	}
 
-	chancleanup();
-
-	/* Most dropbear functions are unsafe to run after this point */
+	/* After these are freed most functions will exit */
 #ifdef DROPBEAR_CLEANUP
 	/* listeners call cleanup functions, this should occur before
 	other session state is freed. */
@@ -289,6 +292,12 @@
 	cleanup_buf(&ses.payload);
 	cleanup_buf(&ses.readbuf);
 	cleanup_buf(&ses.writepayload);
+	cleanup_buf(&ses.kexhashbuf);
+	cleanup_buf(&ses.transkexinit);
+	if (ses.dh_K) {
+		mp_clear(ses.dh_K);
+	}
+	m_free(ses.dh_K);
 
 	m_burn(ses.keys, sizeof(struct key_context));
 	m_free(ses.keys);
--- a/svr-session.c	Tue Feb 24 22:01:33 2015 +0800
+++ b/svr-session.c	Tue Feb 24 22:17:04 2015 +0800
@@ -83,8 +83,9 @@
 	svr_pubkey_options_cleanup();
 
 	m_free(svr_ses.addrstring);
+	m_free(svr_ses.remotehost);
 	m_free(svr_ses.childpids);
-	m_free(svr_ses.remotehost);
+	svr_ses.childpidsize = 0;
 }
 
 static void