]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-journal: refuse entry objects with an empty boot ID
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 21 Sep 2023 20:08:12 +0000 (05:08 +0900)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 22 Sep 2023 06:05:53 +0000 (08:05 +0200)
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.

src/libsystemd/sd-journal/journal-file.c

index 0447bcde57774423ebc8a21cd70eab780721bc62..ef860d228b9d548b7d53f542142322729061a5d1 100644 (file)
@@ -991,6 +991,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;
         }