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.
This commit is contained in:
Daan De Meyer 2021-11-03 14:37:55 +00:00
parent c92f1ebe5d
commit d06727aec2

View 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;