summaryrefslogtreecommitdiff
path: root/src/journal/journal-file.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/journal/journal-file.c')
-rw-r--r--src/journal/journal-file.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
index 80775e1acf..6c7718de31 100644
--- a/src/journal/journal-file.c
+++ b/src/journal/journal-file.c
@@ -241,6 +241,10 @@ static int journal_file_map(
wsize = size + (offset - woffset);
wsize = PAGE_ALIGN(wsize);
+ /* Avoid SIGBUS on invalid accesses */
+ if (woffset + wsize > (uint64_t) PAGE_ALIGN(f->last_stat.st_size))
+ return -EADDRNOTAVAIL;
+
window = mmap(NULL, wsize, f->prot, MAP_SHARED, f->fd, woffset);
if (window == MAP_FAILED)
return -errno;
@@ -305,6 +309,15 @@ static int journal_file_move_to(JournalFile *f, int wt, uint64_t offset, uint64_
} else
delta = 0;
+ if (offset > (uint64_t) f->last_stat.st_size)
+ return -EADDRNOTAVAIL;
+
+ if (offset + size > (uint64_t) f->last_stat.st_size)
+ size = PAGE_ALIGN((uint64_t) f->last_stat.st_size - offset);
+
+ if (size <= 0)
+ return -EADDRNOTAVAIL;
+
r = journal_file_map(f,
offset, size,
&w->ptr, &w->offset, &w->size,