summaryrefslogtreecommitdiffhomepage
path: root/svr-authpubkeyoptions.c
diff options
context:
space:
mode:
authorMatt Johnston <matt@ucc.asn.au>2011-12-04 05:31:25 +0800
committerMatt Johnston <matt@ucc.asn.au>2011-12-04 05:31:25 +0800
commitaec23e5f791b78ed195358057f07f3050ab5bf94 (patch)
tree811346f9bbbcf950da16f1d6b992bf88f11aef6f /svr-authpubkeyoptions.c
parent52a466b8afa32a1355dcbc90936eedcf5d740b1d (diff)
- Fix use-after-free if multiple command requests were sent. Move
the original_command into chansess struct since that makes more sense
Diffstat (limited to 'svr-authpubkeyoptions.c')
-rw-r--r--svr-authpubkeyoptions.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/svr-authpubkeyoptions.c b/svr-authpubkeyoptions.c
index fd87703..4490b58 100644
--- a/svr-authpubkeyoptions.c
+++ b/svr-authpubkeyoptions.c
@@ -92,14 +92,15 @@ int svr_pubkey_allows_pty() {
* by any 'command' public key option. */
void svr_pubkey_set_forced_command(struct ChanSess *chansess) {
if (ses.authstate.pubkey_options) {
- ses.authstate.pubkey_options->original_command = chansess->cmd;
- if (!chansess->cmd)
- {
- ses.authstate.pubkey_options->original_command = m_strdup("");
+ if (chansess->cmd) {
+ /* original_command takes ownership */
+ chansess->original_command = chansess->cmd;
+ } else {
+ chansess->original_command = m_strdup("");
}
- chansess->cmd = ses.authstate.pubkey_options->forced_command;
+ chansess->cmd = m_strdup(ses.authstate.pubkey_options->forced_command);
#ifdef LOG_COMMANDS
- dropbear_log(LOG_INFO, "Command forced to '%s'", ses.authstate.pubkey_options->original_command);
+ dropbear_log(LOG_INFO, "Command forced to '%s'", chansess->original_command);
#endif
}
}