diff options
author | Lennart Poettering <lennart@poettering.net> | 2017-02-02 18:30:29 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2017-02-02 20:12:31 +0100 |
commit | 1bb4b028a380d74cff6399ea1d8ffcf1b2f122bc (patch) | |
tree | 041f20a932fbf9d318cf5484bf5e22e8cddae5bc /src/shared/logs-show.c | |
parent | c477ff141b875a2a98c90514b6bf23f0436d1f73 (diff) |
time-util: refuse formatting/parsing times that we can't store
usec_t is always 64bit, which means it can cover quite a number of
years. However, 4 digit year display and glibc limitations around time_t
limit what we can actually parse and format. Let's make this explicit,
so that we never end up formatting dates we can#t parse and vice versa.
Note that this is really just about formatting/parsing. Internal
calculations with times outside of the formattable range are not
affected.
Diffstat (limited to 'src/shared/logs-show.c')
-rw-r--r-- | src/shared/logs-show.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/shared/logs-show.c b/src/shared/logs-show.c index 75ea25c8ac..72c43e80cb 100644 --- a/src/shared/logs-show.c +++ b/src/shared/logs-show.c @@ -246,6 +246,11 @@ static int output_timestamp_realtime(FILE *f, sd_journal *j, OutputMode mode, Ou if (r < 0) return log_error_errno(r, "Failed to get realtime timestamp: %m"); + if (x > USEC_TIMESTAMP_FORMATTABLE_MAX) { + log_error("Timestamp cannot be printed"); + return -EINVAL; + } + if (mode == OUTPUT_SHORT_FULL) { const char *k; |