[systemd-commits] src/journal
Lennart Poettering
lennart at kemper.freedesktop.org
Mon Sep 10 02:58:24 PDT 2012
src/journal/journal-file.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
New commits:
commit 7762e02b172913e8af82f6ba013487527413be84
Author: Lennart Poettering <lennart at poettering.net>
Date: Mon Sep 10 11:58:00 2012 +0200
journald: detect invalid header pointers correctly
diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
index 06de2ac..c8193ba 100644
--- a/src/journal/journal-file.c
+++ b/src/journal/journal-file.c
@@ -221,10 +221,16 @@ static int journal_file_verify_header(JournalFile *f) {
if (le64toh(f->header->tail_object_offset) > (le64toh(f->header->header_size) + le64toh(f->header->arena_size)))
return -ENODATA;
- if (!VALID64(f->header->data_hash_table_offset) ||
- !VALID64(f->header->field_hash_table_offset) ||
- !VALID64(f->header->tail_object_offset) ||
- !VALID64(f->header->entry_array_offset))
+ if (!VALID64(le64toh(f->header->data_hash_table_offset)) ||
+ !VALID64(le64toh(f->header->field_hash_table_offset)) ||
+ !VALID64(le64toh(f->header->tail_object_offset)) ||
+ !VALID64(le64toh(f->header->entry_array_offset)))
+ return -ENODATA;
+
+ if (le64toh(f->header->data_hash_table_offset) < le64toh(f->header->header_size) ||
+ le64toh(f->header->field_hash_table_offset) < le64toh(f->header->header_size) ||
+ le64toh(f->header->tail_object_offset) < le64toh(f->header->header_size) ||
+ le64toh(f->header->entry_array_offset) < le64toh(f->header->header_size))
return -ENODATA;
if (f->writable) {
@@ -323,6 +329,9 @@ static int journal_file_move_to(JournalFile *f, int context, bool keep_always, u
assert(f);
assert(ret);
+ if (size <= 0)
+ return -EINVAL;
+
/* Avoid SIGBUS on invalid accesses */
if (offset + size > (uint64_t) f->last_stat.st_size) {
/* Hmm, out of range? Let's refresh the fstat() data
More information about the systemd-commits
mailing list