From 2dee23ebe09965308c67a661ed0a8d2cc0ae1d5f Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 16 Aug 2012 20:51:24 +0200 Subject: journal: count number of entry arrays in header --- src/journal/journal-def.h | 1 + src/journal/journal-file.c | 3 +++ src/journal/journal-verify.c | 7 +++++++ 3 files changed, 11 insertions(+) (limited to 'src/journal') diff --git a/src/journal/journal-def.h b/src/journal/journal-def.h index e61e81ca84..660a92c147 100644 --- a/src/journal/journal-def.h +++ b/src/journal/journal-def.h @@ -185,6 +185,7 @@ _packed_ struct Header { le64_t n_fields; /* Added in 189 */ le64_t n_tags; + le64_t n_entry_arrays; }; #define FSPRG_HEADER_SIGNATURE ((char[]) { 'K', 'S', 'H', 'H', 'R', 'H', 'L', 'P' }) diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c index e0b20ccefd..81952a08ee 100644 --- a/src/journal/journal-file.c +++ b/src/journal/journal-file.c @@ -839,6 +839,9 @@ static int link_entry_into_array(JournalFile *f, o->entry_array.next_entry_array_offset = htole64(q); } + if (JOURNAL_HEADER_CONTAINS(f->header, n_entry_arrays)) + f->header->n_entry_arrays = htole64(le64toh(f->header->n_entry_arrays) + 1); + *idx = htole64(hidx + 1); return 0; diff --git a/src/journal/journal-verify.c b/src/journal/journal-verify.c index 55ca52a641..b4e34d18a8 100644 --- a/src/journal/journal-verify.c +++ b/src/journal/journal-verify.c @@ -837,6 +837,13 @@ int journal_file_verify(JournalFile *f, const char *key) { goto fail; } + if (JOURNAL_HEADER_CONTAINS(f->header, n_entry_arrays) && + n_entry_arrays != le64toh(f->header->n_entry_arrays)) { + log_error("Entry array number mismatch"); + r = -EBADMSG; + goto fail; + } + if (n_data_hash_tables != 1) { log_error("Missing data hash table"); r = -EBADMSG; -- cgit v1.2.1