comparison 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
comparison
equal deleted inserted replaced
1330:0d889b068123 1331:ab06e093d1e1
93 void svr_pubkey_set_forced_command(struct ChanSess *chansess) { 93 void svr_pubkey_set_forced_command(struct ChanSess *chansess) {
94 if (ses.authstate.pubkey_options && ses.authstate.pubkey_options->forced_command) { 94 if (ses.authstate.pubkey_options && ses.authstate.pubkey_options->forced_command) {
95 if (chansess->cmd) { 95 if (chansess->cmd) {
96 /* original_command takes ownership */ 96 /* original_command takes ownership */
97 chansess->original_command = chansess->cmd; 97 chansess->original_command = chansess->cmd;
98 chansess->cmd = NULL;
98 } else { 99 } else {
99 chansess->original_command = m_strdup(""); 100 chansess->original_command = m_strdup("");
100 } 101 }
101 chansess->cmd = m_strdup(ses.authstate.pubkey_options->forced_command); 102 chansess->cmd = m_strdup(ses.authstate.pubkey_options->forced_command);
102 #ifdef LOG_COMMANDS 103 #ifdef LOG_COMMANDS
106 } 107 }
107 108
108 /* Free potential public key options */ 109 /* Free potential public key options */
109 void svr_pubkey_options_cleanup() { 110 void svr_pubkey_options_cleanup() {
110 if (ses.authstate.pubkey_options) { 111 if (ses.authstate.pubkey_options) {
112 if (ses.authstate.pubkey_options->forced_command) {
113 m_free(ses.authstate.pubkey_options->forced_command);
114 }
111 m_free(ses.authstate.pubkey_options); 115 m_free(ses.authstate.pubkey_options);
112 ses.authstate.pubkey_options = NULL; 116 ses.authstate.pubkey_options = NULL;
113 } 117 }
114 } 118 }
115 119
198 ret = DROPBEAR_SUCCESS; 202 ret = DROPBEAR_SUCCESS;
199 goto end; 203 goto end;
200 204
201 bad_option: 205 bad_option:
202 ret = DROPBEAR_FAILURE; 206 ret = DROPBEAR_FAILURE;
203 m_free(ses.authstate.pubkey_options); 207 svr_pubkey_options_cleanup();
204 ses.authstate.pubkey_options = NULL;
205 dropbear_log(LOG_WARNING, "Bad public key options at %s:%d", filename, line_num); 208 dropbear_log(LOG_WARNING, "Bad public key options at %s:%d", filename, line_num);
206 209
207 end: 210 end:
208 TRACE(("leave addpubkeyoptions")) 211 TRACE(("leave addpubkeyoptions"))
209 return ret; 212 return ret;