comparison 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
comparison
equal deleted inserted replaced
1040:2b4fd440399d 1041:3fb883a6aa81
258 if (!sessinitdone) { 258 if (!sessinitdone) {
259 TRACE(("leave session_cleanup: !sessinitdone")) 259 TRACE(("leave session_cleanup: !sessinitdone"))
260 return; 260 return;
261 } 261 }
262 262
263 /* Beware of changing order of functions here. */
264
265 /* Must be before extra_session_cleanup() */
266 chancleanup();
267
263 if (ses.extra_session_cleanup) { 268 if (ses.extra_session_cleanup) {
264 ses.extra_session_cleanup(); 269 ses.extra_session_cleanup();
265 } 270 }
266 271
267 chancleanup(); 272 /* After these are freed most functions will exit */
268
269 /* Most dropbear functions are unsafe to run after this point */
270 #ifdef DROPBEAR_CLEANUP 273 #ifdef DROPBEAR_CLEANUP
271 /* listeners call cleanup functions, this should occur before 274 /* listeners call cleanup functions, this should occur before
272 other session state is freed. */ 275 other session state is freed. */
273 remove_all_listeners(); 276 remove_all_listeners();
274 277
287 cleanup_buf(&ses.session_id); 290 cleanup_buf(&ses.session_id);
288 cleanup_buf(&ses.hash); 291 cleanup_buf(&ses.hash);
289 cleanup_buf(&ses.payload); 292 cleanup_buf(&ses.payload);
290 cleanup_buf(&ses.readbuf); 293 cleanup_buf(&ses.readbuf);
291 cleanup_buf(&ses.writepayload); 294 cleanup_buf(&ses.writepayload);
295 cleanup_buf(&ses.kexhashbuf);
296 cleanup_buf(&ses.transkexinit);
297 if (ses.dh_K) {
298 mp_clear(ses.dh_K);
299 }
300 m_free(ses.dh_K);
292 301
293 m_burn(ses.keys, sizeof(struct key_context)); 302 m_burn(ses.keys, sizeof(struct key_context));
294 m_free(ses.keys); 303 m_free(ses.keys);
295 304
296 TRACE(("leave session_cleanup")) 305 TRACE(("leave session_cleanup"))