summaryrefslogtreecommitdiff
path: root/src/basic/time-util.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-05-21 20:39:09 +0200
committerSven Eden <yamakuzure@gmx.net>2018-08-24 16:47:08 +0200
commit0fd6a0f934d6ad4d553a4b81dd4c7549dd440c37 (patch)
treea241d166a6772f1484ba10ce5f947e1f2f709590 /src/basic/time-util.c
parent4200259f1ff34f40654440388f8e4a401f71c080 (diff)
Always allow timestamps to be printed
If the timestamp is above 9999-12-30, (or 2038-something-something on 32 bit), use XXXX-XX-XX XX:XX:XX as the replacement. The problem with refusing to print timestamps is that our code accepts such timestamps, so we can't really just refuse to process them afterwards. Also, it makes journal files non-portable, because suddently we might completely refuse to print entries which are totally OK on a different machine.
Diffstat (limited to 'src/basic/time-util.c')
-rw-r--r--src/basic/time-util.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/basic/time-util.c b/src/basic/time-util.c
index fc9b99f51..734844731 100644
--- a/src/basic/time-util.c
+++ b/src/basic/time-util.c
@@ -288,8 +288,11 @@ static char *format_timestamp_internal(
return NULL; /* Timestamp is unset */
/* Let's not format times with years > 9999 */
- if (t > USEC_TIMESTAMP_FORMATTABLE_MAX)
- return NULL;
+ if (t > USEC_TIMESTAMP_FORMATTABLE_MAX) {
+ assert(l >= strlen("--- XXXX-XX-XX XX:XX:XX") + 1);
+ strcpy(buf, "--- XXXX-XX-XX XX:XX:XX");
+ return buf;
+ }
sec = (time_t) (t / USEC_PER_SEC); /* Round down */