summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2016-10-12 12:12:58 +0200
committerLennart Poettering <lennart@poettering.net>2016-10-12 20:25:20 +0200
commitded5034e7a3e7b3330bbe4f5dd13ca994785d6cb (patch)
treee26cac3dcc985c9eab7da82dc107e979e847332a /src
parentb6da4ed0450ced53a911d974c8b1da6ad9ff212a (diff)
journal: also check that our entry arrays are properly ordered
Let's and extra check, reusing check_properly_ordered() also for journal_file_next_entry_for_data().
Diffstat (limited to 'src')
-rw-r--r--src/journal/journal-file.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
index 52562cd0b8..f59858277e 100644
--- a/src/journal/journal-file.c
+++ b/src/journal/journal-file.c
@@ -2583,7 +2583,7 @@ int journal_file_next_entry_for_data(
direction_t direction,
Object **ret, uint64_t *offset) {
- uint64_t n, i;
+ uint64_t i, n, ofs;
int r;
Object *d;
@@ -2622,11 +2622,24 @@ int journal_file_next_entry_for_data(
return r;
}
- return generic_array_get_plus_one(f,
- le64toh(d->data.entry_offset),
- le64toh(d->data.entry_array_offset),
- i,
- ret, offset);
+ r = generic_array_get_plus_one(f,
+ le64toh(d->data.entry_offset),
+ le64toh(d->data.entry_array_offset),
+ i,
+ ret, &ofs);
+ if (r <= 0)
+ return r;
+
+ /* Ensure our array is properly ordered. */
+ if (p > 0 && check_properly_ordered(ofs, p, direction)) {
+ log_debug("%s data entry array not properly ordered at entry %" PRIu64, f->path, i);
+ return -EBADMSG;
+ }
+
+ if (offset)
+ *offset = ofs;
+
+ return 1;
}
int journal_file_move_to_entry_by_offset_for_data(