summaryrefslogtreecommitdiffhomepage
path: root/svr-session.c
diff options
context:
space:
mode:
authorMatt Johnston <matt@ucc.asn.au>2007-02-03 09:58:14 +0000
committerMatt Johnston <matt@ucc.asn.au>2007-02-03 09:58:14 +0000
commit28f1026de851c17b2b0bfbefaf07e2f52e29ac4b (patch)
tree577b1f9c08b7017b8c9e7fc9ebb1f6ea65de1920 /svr-session.c
parent85f22c9f098e853a6c6836d1af8afcee3ea6c4b7 (diff)
Fix potential null pointer dereference found by Klokwork
--HG-- extra : convert_revision : ef7030b29eca0944e6fbbdcdd776aafe39197ffa
Diffstat (limited to 'svr-session.c')
-rw-r--r--svr-session.c11
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(&timesec)) == 0) {
- datestr[0] = '?'; datestr[1] = '\0';
+ local_tm = localtime(&timesec);
+ if (local_tm == NULL
+ || strftime(datestr, sizeof(datestr), "%b %d %H:%M:%S",
+ localtime(&timesec)) == 0)
+ {
+ // upon failure, just print the epoch-seconds time.
+ snprintf(datestr, sizeof(datestr), "%d", timesec);
}
fprintf(stderr, "[%d] %s %s\n", getpid(), datestr, printbuf);
}