summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDaan De Meyer <daan.j.demeyer@gmail.com>2021-11-03 15:37:55 +0100
committerDaan De Meyer <daan.j.demeyer@gmail.com>2022-10-07 12:20:08 +0200
commitd06727aec2840dc3d6d1cb2b7032562eda8bf3b4 (patch)
treec4dcd2ed8433cd3653fba9e6a59df489a7f0ca96 /src
parentjournal: Run unit tests with and without compact mode enabled (diff)
downloadsystemd-d06727aec2840dc3d6d1cb2b7032562eda8bf3b4.tar.xz
systemd-d06727aec2840dc3d6d1cb2b7032562eda8bf3b4.zip
journal: Don't allocate objects above UINT32_MAX in compact mode
To allow storing offsets as 32-bit, we should never allocate objects outside of the 32-bit range.
Diffstat (limited to '')
-rw-r--r--src/libsystemd/sd-journal/journal-file.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/libsystemd/sd-journal/journal-file.c b/src/libsystemd/sd-journal/journal-file.c
index 906e69f390..edec27610f 100644
--- a/src/libsystemd/sd-journal/journal-file.c
+++ b/src/libsystemd/sd-journal/journal-file.c
@@ -586,6 +586,10 @@ static int journal_file_allocate(JournalFile *f, uint64_t offset, uint64_t size)
if (f->metrics.max_size > 0 && new_size > f->metrics.max_size)
return -E2BIG;
+ /* Refuse to go over 4G in compact mode so offsets can be stored in 32-bit. */
+ if (JOURNAL_HEADER_COMPACT(f->header) && new_size > UINT32_MAX)
+ return -E2BIG;
+
if (new_size > f->metrics.min_size && f->metrics.keep_free > 0) {
struct statvfs svfs;