Mercurial > dropbear
changeset 404:a588558bfc94
Fix potential null pointer dereference found by Klokwork
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Sat, 03 Feb 2007 09:58:14 +0000 |
parents | 75940fef22dd |
children | 00703f1df67a |
files | svr-session.c |
diffstat | 1 files changed, 8 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/svr-session.c Sat Feb 03 09:42:22 2007 +0000 +++ b/svr-session.c Sat Feb 03 09:58:14 2007 +0000 @@ -181,10 +181,15 @@ 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); }