]> www.infradead.org Git - users/mchehab/rasdaemon.git/commitdiff
rasdaemon: ras-memory-failure-handler: handle localtime() failure correctly
authorAristeu Rozanski <arozansk@redhat.com>
Thu, 19 Jan 2023 13:45:57 +0000 (08:45 -0500)
committerMauro Carvalho Chehab <mchehab@kernel.org>
Sat, 21 Jan 2023 06:27:38 +0000 (07:27 +0100)
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 <arozansk@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
ras-memory-failure-handler.c

index 9941e6877fb5288048520b3759de7e7f969b7f1e..1951456a67524c3bb57b93eccc1537dd2576c7fc 100644 (file)
@@ -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)