diff options
Diffstat (limited to 'svr-session.c')
-rw-r--r-- | svr-session.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/svr-session.c b/svr-session.c index 70029f8..fe78bcc 100644 --- a/svr-session.c +++ b/svr-session.c @@ -181,10 +181,15 @@ void svr_dropbear_log(int priority, const char* format, va_list param) { if (!svr_opts.usingsyslog || havetrace) { + struct tm * local_tm = NULL; timesec = time(NULL); - if (strftime(datestr, sizeof(datestr), "%b %d %H:%M:%S", - localtime(×ec)) == 0) { - datestr[0] = '?'; datestr[1] = '\0'; + local_tm = localtime(×ec); + if (local_tm == NULL + || strftime(datestr, sizeof(datestr), "%b %d %H:%M:%S", + localtime(×ec)) == 0) + { + // upon failure, just print the epoch-seconds time. + snprintf(datestr, sizeof(datestr), "%d", timesec); } fprintf(stderr, "[%d] %s %s\n", getpid(), datestr, printbuf); } |