From 26ac516fd197b2c7a0867472e826290a641de9ac Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Fri, 22 Sep 2023 05:08:12 +0900 Subject: [PATCH] sd-journal: refuse entry objects with an empty boot ID Otherwise, e.g. sd_journal_get_monotonic_usec() return an empty boot ID when called for such a broken entry object. Such a broken object may be stored when the system was not cleanly shutdown. Fixes #29167. (cherry picked from commit c650d4cdef5c1b87237193995f08d7e2d1be0c44) Conflict:NA Reference:https://github.com/systemd/systemd-stable/commit/26ac516fd197b2c7a0867472e826290a641de9ac --- src/libsystemd/sd-journal/journal-file.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/libsystemd/sd-journal/journal-file.c b/src/libsystemd/sd-journal/journal-file.c index 67819e880f..ab1d3ca04d 100644 --- a/src/libsystemd/sd-journal/journal-file.c +++ b/src/libsystemd/sd-journal/journal-file.c @@ -993,6 +993,11 @@ static int check_object(JournalFile *f, Object *o, uint64_t offset) { le64toh(o->entry.monotonic), offset); + if (sd_id128_is_null(o->entry.boot_id)) + return log_debug_errno(SYNTHETIC_ERRNO(EBADMSG), + "Invalid object entry with an empty boot ID: %" PRIu64, + offset); + break; } -- 2.33.0