Skip to content
Snippets Groups Projects
Commit 28f1026d authored by Matt Johnston's avatar Matt Johnston
Browse files

Fix potential null pointer dereference found by Klokwork

--HG--
extra : convert_revision : ef7030b29eca0944e6fbbdcdd776aafe39197ffa
parent 85f22c9f
Branches
Tags
No related merge requests found
......@@ -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);
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment