]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
journal: Don't allocate objects above UINT32_MAX in compact mode
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 3 Nov 2021 14:37:55 +0000 (14:37 +0000)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 7 Oct 2022 10:20:08 +0000 (12:20 +0200)
To allow storing offsets as 32-bit, we should never allocate objects
outside of the 32-bit range.

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

index 906e69f39034112829771f6d4a15b6160023f083..edec27610f64c78c9e5b32057fb6cc12e94fe195 100644 (file)
@@ -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;