diff common-session.c @ 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 01eea88963f3
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);