diff svr-authpubkeyoptions.c @ 1331:ab06e093d1e1

free forced_command
author Matt Johnston <matt@ucc.asn.au>
date Wed, 10 May 2017 00:20:33 +0800
parents 5709b15a1b57
children 8747c2b19152
line wrap: on
line diff
--- a/svr-authpubkeyoptions.c	Wed May 10 00:20:21 2017 +0800
+++ b/svr-authpubkeyoptions.c	Wed May 10 00:20:33 2017 +0800
@@ -95,6 +95,7 @@
 		if (chansess->cmd) {
 			/* original_command takes ownership */
 			chansess->original_command = chansess->cmd;
+			chansess->cmd = NULL;
 		} else {
 			chansess->original_command = m_strdup("");
 		}
@@ -108,6 +109,9 @@
 /* Free potential public key options */
 void svr_pubkey_options_cleanup() {
 	if (ses.authstate.pubkey_options) {
+		if (ses.authstate.pubkey_options->forced_command) {
+			m_free(ses.authstate.pubkey_options->forced_command);
+		}
 		m_free(ses.authstate.pubkey_options);
 		ses.authstate.pubkey_options = NULL;
 	}
@@ -200,8 +204,7 @@
 
 bad_option:
 	ret = DROPBEAR_FAILURE;
-	m_free(ses.authstate.pubkey_options);
-	ses.authstate.pubkey_options = NULL;
+	svr_pubkey_options_cleanup();
 	dropbear_log(LOG_WARNING, "Bad public key options at %s:%d", filename, line_num);
 
 end: