diff options
author | Lennart Poettering <lennart@poettering.net> | 2023-01-19 20:28:34 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2023-01-21 10:46:02 +0100 |
commit | 404803e6caad2de2d8e74caab0b79ec3f030f801 (patch) | |
tree | 1bf386f8498f7debb0d0a5df6723e1165fbe6d67 /src/libsystemd/sd-journal/sd-journal.c | |
parent | string-util: add common implementation of function that converts sized charac... (diff) | |
download | systemd-404803e6caad2de2d8e74caab0b79ec3f030f801.tar.xz systemd-404803e6caad2de2d8e74caab0b79ec3f030f801.zip |
sd-journal: validate monotonic timestamp before returning it
Diffstat (limited to '')
-rw-r--r-- | src/libsystemd/sd-journal/sd-journal.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/libsystemd/sd-journal/sd-journal.c b/src/libsystemd/sd-journal/sd-journal.c index 035d7ccef8..523e23925d 100644 --- a/src/libsystemd/sd-journal/sd-journal.c +++ b/src/libsystemd/sd-journal/sd-journal.c @@ -2190,8 +2190,8 @@ _public_ int sd_journal_get_realtime_usec(sd_journal *j, uint64_t *ret) { } _public_ int sd_journal_get_monotonic_usec(sd_journal *j, uint64_t *ret, sd_id128_t *ret_boot_id) { - Object *o; JournalFile *f; + Object *o; int r; assert_return(j, -EINVAL); @@ -2200,7 +2200,6 @@ _public_ int sd_journal_get_monotonic_usec(sd_journal *j, uint64_t *ret, sd_id12 f = j->current_file; if (!f) return -EADDRNOTAVAIL; - if (f->current_offset <= 0) return -EADDRNOTAVAIL; @@ -2221,8 +2220,12 @@ _public_ int sd_journal_get_monotonic_usec(sd_journal *j, uint64_t *ret, sd_id12 return -ESTALE; } + uint64_t t = le64toh(o->entry.monotonic); + if (!VALID_MONOTONIC(t)) + return -EBADMSG; + if (ret) - *ret = le64toh(o->entry.monotonic); + *ret = t; return 0; } |