From 3f74a81f650e4caaa12afc7e070323fa27425271 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 21 Jan 2026 23:48:14 +0100 Subject: [PATCH 1/2] journal: some whitespace fixes --- src/journal-remote/journal-remote-write.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/journal-remote/journal-remote-write.c b/src/journal-remote/journal-remote-write.c index 12f519bb2a..5e244ccd19 100644 --- a/src/journal-remote/journal-remote-write.c +++ b/src/journal-remote/journal-remote-write.c @@ -12,6 +12,8 @@ static int do_rotate(JournalFile **f, MMapCache *m, JournalFileFlags file_flags) { int r; + assert(f); + r = journal_file_rotate(f, m, file_flags, UINT64_MAX, NULL); if (r < 0) { if (*f) @@ -95,9 +97,11 @@ int writer_write(Writer *w, if (journal_file_rotate_suggested(w->journal, 0, LOG_DEBUG)) { log_info("%s: Journal header limits reached or header out-of-date, rotating", w->journal->path); + r = do_rotate(&w->journal, w->mmap, file_flags); if (r < 0) return r; + r = journal_directory_vacuum(w->output, w->metrics.max_use, w->metrics.n_max_files, 0, NULL, /* verbose= */ true); if (r < 0) return r; @@ -117,15 +121,16 @@ int writer_write(Writer *w, if (w->server) w->server->event_count += 1; return 0; - } else if (r == -EBADMSG) + } + if (r == -EBADMSG) return r; log_debug_errno(r, "%s: Write failed, rotating: %m", w->journal->path); r = do_rotate(&w->journal, w->mmap, file_flags); if (r < 0) return r; - else - log_debug("%s: Successfully rotated journal", w->journal->path); + + log_debug("%s: Successfully rotated journal", w->journal->path); r = journal_directory_vacuum(w->output, w->metrics.max_use, w->metrics.n_max_files, 0, NULL, /* verbose= */ true); if (r < 0) return r; From 1efc26343307c4fcdeb383e25b17a8494493b273 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 21 Jan 2026 23:48:29 +0100 Subject: [PATCH 2/2] journal: do not use typecasts for range checks --- src/libsystemd/sd-journal/journal-file.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libsystemd/sd-journal/journal-file.c b/src/libsystemd/sd-journal/journal-file.c index 8dcd599bbd..de5d7075e0 100644 --- a/src/libsystemd/sd-journal/journal-file.c +++ b/src/libsystemd/sd-journal/journal-file.c @@ -1940,8 +1940,10 @@ static int maybe_decompress_payload( assert(f); /* We can't read objects larger than 4G on a 32-bit machine */ - if ((uint64_t) (size_t) size != size) +#if __SIZEOF_SIZE_T__ == 4 + if (size > UINT32_MAX) return -E2BIG; +#endif if (compression != COMPRESSION_NONE) { #if HAVE_COMPRESSION