free forced_command

This commit is contained in:
Matt Johnston 2017-05-10 00:20:33 +08:00
parent 93f3c31807
commit bda3bc4c8d

View File

@ -95,6 +95,7 @@ void svr_pubkey_set_forced_command(struct ChanSess *chansess) {
if (chansess->cmd) { if (chansess->cmd) {
/* original_command takes ownership */ /* original_command takes ownership */
chansess->original_command = chansess->cmd; chansess->original_command = chansess->cmd;
chansess->cmd = NULL;
} else { } else {
chansess->original_command = m_strdup(""); chansess->original_command = m_strdup("");
} }
@ -108,6 +109,9 @@ void svr_pubkey_set_forced_command(struct ChanSess *chansess) {
/* Free potential public key options */ /* Free potential public key options */
void svr_pubkey_options_cleanup() { void svr_pubkey_options_cleanup() {
if (ses.authstate.pubkey_options) { 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); m_free(ses.authstate.pubkey_options);
ses.authstate.pubkey_options = NULL; ses.authstate.pubkey_options = NULL;
} }
@ -200,8 +204,7 @@ next_option:
bad_option: bad_option:
ret = DROPBEAR_FAILURE; ret = DROPBEAR_FAILURE;
m_free(ses.authstate.pubkey_options); svr_pubkey_options_cleanup();
ses.authstate.pubkey_options = NULL;
dropbear_log(LOG_WARNING, "Bad public key options at %s:%d", filename, line_num); dropbear_log(LOG_WARNING, "Bad public key options at %s:%d", filename, line_num);
end: end: