krishnanadh / rpms / rasdaemon

Forked from rpms/rasdaemon a year ago
Clone

Blame SOURCES/ce33041e0abfa20054ff5d6874ffbd1ab592558d.patch

f6ed37
commit ce33041e0abfa20054ff5d6874ffbd1ab592558d
f6ed37
Author: Aristeu Rozanski <arozansk@redhat.com>
f6ed37
Date:   Thu Jan 19 08:45:57 2023 -0500
f6ed37
f6ed37
    rasdaemon: ras-memory-failure-handler: handle localtime() failure correctly
f6ed37
    
f6ed37
    We could just have an empty string but keeping the format could prevent
f6ed37
    issues if someone is actually parsing this.
f6ed37
    Found with covscan.
f6ed37
    
f6ed37
    v2: fixed the timestamp as pointed by Robert Elliott
f6ed37
    
f6ed37
    Signed-off-by: Aristeu Rozanski <arozansk@redhat.com>
f6ed37
    Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
f6ed37
f6ed37
diff --git a/ras-memory-failure-handler.c b/ras-memory-failure-handler.c
f6ed37
index 9941e68..1951456 100644
f6ed37
--- a/ras-memory-failure-handler.c
f6ed37
+++ b/ras-memory-failure-handler.c
f6ed37
@@ -148,6 +148,8 @@ int ras_memory_failure_event_handler(struct trace_seq *s,
f6ed37
 	if (tm)
f6ed37
 		strftime(ev.timestamp, sizeof(ev.timestamp),
f6ed37
 			 "%Y-%m-%d %H:%M:%S %z", tm);
f6ed37
+	else
f6ed37
+		strncpy(ev.timestamp, "1970-01-01 00:00:00 +0000", sizeof(ev.timestamp));
f6ed37
 	trace_seq_printf(s, "%s ", ev.timestamp);
f6ed37
 
f6ed37
 	if (pevent_get_field_val(s,  event, "pfn", record, &val, 1) < 0)