summaryrefslogtreecommitdiff
path: root/cli-main.c
diff options
context:
space:
mode:
Diffstat (limited to 'cli-main.c')
-rw-r--r--cli-main.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/cli-main.c b/cli-main.c
index ff2b30f..c7c9035 100644
--- a/cli-main.c
+++ b/cli-main.c
@@ -87,6 +87,7 @@ int main(int argc, char ** argv) {
static void cli_dropbear_exit(int exitcode, const char* format, va_list param) {
char fmtbuf[300];
+ char exitmsg[500];
if (!sessinitdone) {
snprintf(fmtbuf, sizeof(fmtbuf), "Exited: %s",
@@ -98,12 +99,15 @@ static void cli_dropbear_exit(int exitcode, const char* format, va_list param) {
cli_opts.remoteport, format);
}
+ /* Arguments to the exit printout may be unsafe to use after session_cleanup() */
+ vsnprintf(exitmsg, sizeof(exitmsg), fmtbuf, param);
+
/* Do the cleanup first, since then the terminal will be reset */
session_cleanup();
/* Avoid printing onwards from terminal cruft */
fprintf(stderr, "\n");
- _dropbear_log(LOG_INFO, fmtbuf, param);
+ dropbear_log(LOG_INFO, "%s", exitmsg);;
exit(exitcode);
}