Fix potential null pointer dereference found by Klokwork

--HG--
extra : convert_revision : ef7030b29eca0944e6fbbdcdd776aafe39197ffa
This commit is contained in:
Matt Johnston 2007-02-03 09:58:14 +00:00
parent 85f22c9f09
commit 28f1026de8

View File

@ -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);
}