From: Yu Watanabe Date: Fri, 22 Sep 2023 19:14:31 +0000 (+0900) Subject: sd-journal: refuse to write entry without boot ID X-Git-Tag: v255-rc1~414^2~7 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1eede158519e4e5ed22738c90cb57a91dbecb7f2;p=thirdparty%2Fsystemd.git sd-journal: refuse to write entry without boot ID To make journal entries always contain valid boot ID. --- diff --git a/src/libsystemd/sd-journal/journal-file.c b/src/libsystemd/sd-journal/journal-file.c index 872f16b386c..ab25ff87bc3 100644 --- a/src/libsystemd/sd-journal/journal-file.c +++ b/src/libsystemd/sd-journal/journal-file.c @@ -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;