summaryrefslogtreecommitdiffhomepage
path: root/svr-session.c
diff options
context:
space:
mode:
authorMatt Johnston <matt@ucc.asn.au>2016-07-21 23:38:42 +0800
committerMatt Johnston <matt@ucc.asn.au>2016-07-21 23:38:42 +0800
commitc6e912f9e21139494713f408924bfaf17e655824 (patch)
tree13076886cd8a08608039a69c6d8933663d598398 /svr-session.c
parentdd19d73db4e5d6bd8a28120629644ee01824d450 (diff)
parent1df5c97144ba60eb7ae9de8b5b0ea0354a213181 (diff)
merge 2016.74
Diffstat (limited to 'svr-session.c')
-rw-r--r--svr-session.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/svr-session.c b/svr-session.c
index 2fe5220..febe79a 100644
--- a/svr-session.c
+++ b/svr-session.c
@@ -144,31 +144,33 @@ void svr_session(int sock, int childpipe) {
/* failure exit - format must be <= 100 chars */
void svr_dropbear_exit(int exitcode, const char* format, va_list param) {
-
- char fmtbuf[300];
+ char exitmsg[150];
+ char fullmsg[300];
int i;
+ /* Render the formatted exit message */
+ vsnprintf(exitmsg, sizeof(exitmsg), format, param);
+
+ /* Add the prefix depending on session/auth state */
if (!sessinitdone) {
/* before session init */
- snprintf(fmtbuf, sizeof(fmtbuf),
- "Early exit: %s", format);
+ snprintf(fullmsg, sizeof(fullmsg), "Early exit: %s", exitmsg);
} else if (ses.authstate.authdone) {
/* user has authenticated */
- snprintf(fmtbuf, sizeof(fmtbuf),
+ snprintf(fullmsg, sizeof(fullmsg),
"Exit (%s): %s",
- ses.authstate.pw_name, format);
+ ses.authstate.pw_name, exitmsg);
} else if (ses.authstate.pw_name) {
/* we have a potential user */
- snprintf(fmtbuf, sizeof(fmtbuf),
+ snprintf(fullmsg, sizeof(fullmsg),
"Exit before auth (user '%s', %u fails): %s",
- ses.authstate.pw_name, ses.authstate.failcount, format);
+ ses.authstate.pw_name, ses.authstate.failcount, exitmsg);
} else {
/* before userauth */
- snprintf(fmtbuf, sizeof(fmtbuf),
- "Exit before auth: %s", format);
+ snprintf(fullmsg, sizeof(fullmsg), "Exit before auth: %s", exitmsg);
}
- _dropbear_log(LOG_INFO, fmtbuf, param);
+ dropbear_log(LOG_INFO, "%s", fullmsg);
#if DROPBEAR_VFORK
/* For uclinux only the main server process should cleanup - we don't want