From: Aristeu Rozanski Date: Thu, 19 Jan 2023 13:45:57 +0000 (-0500) Subject: rasdaemon: ras-memory-failure-handler: handle localtime() failure correctly X-Git-Tag: v0.7.0~18 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=ce33041e0abfa20054ff5d6874ffbd1ab592558d;p=users%2Fmchehab%2Frasdaemon.git rasdaemon: ras-memory-failure-handler: handle localtime() failure correctly We could just have an empty string but keeping the format could prevent issues if someone is actually parsing this. Found with covscan. v2: fixed the timestamp as pointed by Robert Elliott Signed-off-by: Aristeu Rozanski Signed-off-by: Mauro Carvalho Chehab --- diff --git a/ras-memory-failure-handler.c b/ras-memory-failure-handler.c index 9941e68..1951456 100644 --- a/ras-memory-failure-handler.c +++ b/ras-memory-failure-handler.c @@ -148,6 +148,8 @@ int ras_memory_failure_event_handler(struct trace_seq *s, if (tm) strftime(ev.timestamp, sizeof(ev.timestamp), "%Y-%m-%d %H:%M:%S %z", tm); + else + strncpy(ev.timestamp, "1970-01-01 00:00:00 +0000", sizeof(ev.timestamp)); trace_seq_printf(s, "%s ", ev.timestamp); if (pevent_get_field_val(s, event, "pfn", record, &val, 1) < 0)