]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-journal: refuse to write entry without boot ID
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 22 Sep 2023 19:14:31 +0000 (04:14 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 26 Sep 2023 04:26:22 +0000 (13:26 +0900)
To make journal entries always contain valid boot ID.

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

index 872f16b386c45d2cac13f597f1eb6e43ea883964..ab25ff87bc3851e961cec58edfca0f18ba220635 100644 (file)
@@ -2299,6 +2299,7 @@ static int journal_file_append_entry_internal(
         assert(f->header);
         assert(ts);
         assert(boot_id);
+        assert(!sd_id128_is_null(*boot_id));
         assert(items || n_items == 0);
 
         if (f->strict_order) {
@@ -2528,7 +2529,10 @@ int journal_file_append_entry(
                 ts = &_ts;
         }
 
-        if (!boot_id) {
+        if (boot_id) {
+                if (sd_id128_is_null(*boot_id))
+                        return log_debug_errno(SYNTHETIC_ERRNO(EBADMSG), "Empty boot ID, refusing entry.");
+        } else {
                 r = sd_id128_get_boot(&_boot_id);
                 if (r < 0)
                         return r;