From fa3ab9f7a9fddca0ce8d937bbb0e7546c0874003 Mon Sep 17 00:00:00 2001 From: Balazs Scheidler Date: Sun, 12 May 2024 13:38:13 +0200 Subject: [PATCH] syslog-format: don't try to turn a timestamp to unixtime if one is not present If the timestamp is not actually there in the message, we still tried to call convert_and_normalize_wall_clock_time_to_unix_time_with_tz_hint(), which in turn calls mktime(), which is a heavyweight operation. Let's not do that. Signed-off-by: Balazs Scheidler --- modules/syslogformat/syslog-format.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/syslogformat/syslog-format.c b/modules/syslogformat/syslog-format.c index 83ec3c507f..1aa0b27b9b 100644 --- a/modules/syslogformat/syslog-format.c +++ b/modules/syslogformat/syslog-format.c @@ -270,7 +270,7 @@ _syslog_format_parse_timestamp(LogMessage *msg, UnixTime *stamp, result = scan_rfc5424_timestamp(data, length, &wct); } - if ((parse_flags & LP_NO_PARSE_DATE) == 0) + if (result && (parse_flags & LP_NO_PARSE_DATE) == 0) { convert_and_normalize_wall_clock_time_to_unix_time_with_tz_hint(&wct, stamp, recv_timezone_ofs);