diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-05-24 13:11:12 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-05-31 14:30:23 +0200 |
commit | c627395366bd3911ae4082e371fd73f64be8eed7 (patch) | |
tree | eb90701915d11026918eb16d4c852ed3047da5b5 /src/journal/journal-file.c | |
parent | Use const char* for timestamp strings which we don't plan to modify (diff) | |
download | systemd-c627395366bd3911ae4082e371fd73f64be8eed7.tar.xz systemd-c627395366bd3911ae4082e371fd73f64be8eed7.zip |
journal: refuse an entry with invalid timestamp fields
The journal verification functions would reject such an entry. It would probably
still display fine (because we prefer _SOURCE_REALTIME_TIMESTAMP= if present), but
it seems wrong to create an entry that would not pass verification.
Diffstat (limited to 'src/journal/journal-file.c')
-rw-r--r-- | src/journal/journal-file.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c index da663f0196..8fe4499add 100644 --- a/src/journal/journal-file.c +++ b/src/journal/journal-file.c @@ -1958,7 +1958,16 @@ int journal_file_append_entry(JournalFile *f, const dual_timestamp *ts, const st assert(f->header); assert(iovec || n_iovec == 0); - if (!ts) { + if (ts) { + if (!VALID_REALTIME(ts->realtime)) { + log_debug("Invalid realtime timestamp %"PRIu64", refusing entry.", ts->realtime); + return -EBADMSG; + } + if (!VALID_MONOTONIC(ts->monotonic)) { + log_debug("Invalid monotomic timestamp %"PRIu64", refusing entry.", ts->monotonic); + return -EBADMSG; + } + } else { dual_timestamp_get(&_ts); ts = &_ts; } |