diff mbox series

[3/3,v2] rasdaemon: ras-memory-failure-handler: handle localtime() failure correctly

Message ID 20220720154033.6kup6lark2ddwlrr@redhat.com (mailing list archive)
State New, archived
Headers show
Series None | expand

Commit Message

'arozansk@redhat.com' July 20, 2022, 3:40 p.m. UTC
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>
diff mbox series

Patch

diff --git a/ras-memory-failure-handler.c b/ras-memory-failure-handler.c
index 9941e68..9574141 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)