diff options
author | Matt Johnston <matt@ucc.asn.au> | 2015-03-03 20:53:00 +0800 |
---|---|---|
committer | Matt Johnston <matt@ucc.asn.au> | 2015-03-03 20:53:00 +0800 |
commit | 5dff74109e566b3ed18298974c2d4d8afe6d817a (patch) | |
tree | 6d1bad28a60c04eca3b60e63635407047eb67922 /cli-main.c | |
parent | 20d970a0e2831b497ec68dd20099c7b4b9d53e19 (diff) |
Fix error handling for dbclient async connect
Diffstat (limited to 'cli-main.c')
-rw-r--r-- | cli-main.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -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); } |