summaryrefslogtreecommitdiff
path: root/src/journal/journal-verify.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-07-24 02:00:43 +0200
committerLennart Poettering <lennart@poettering.net>2015-07-24 02:00:43 +0200
commit8dc37a85255f68d62f7af66696cbf6a66401fb2a (patch)
tree233ab750d5dc2e9efdb47d47059199a321c6de01 /src/journal/journal-verify.c
parentdade37d403f1b8c1d7bb2efbe2361f2a3e999613 (diff)
journal: when verifying journal files, handle empty ones nicely
A journal file that carries no objects should be considered valid.
Diffstat (limited to 'src/journal/journal-verify.c')
-rw-r--r--src/journal/journal-verify.c37
1 files changed, 14 insertions, 23 deletions
diff --git a/src/journal/journal-verify.c b/src/journal/journal-verify.c
index 7d68149cd4..637162e305 100644
--- a/src/journal/journal-verify.c
+++ b/src/journal/journal-verify.c
@@ -885,7 +885,11 @@ int journal_file_verify(
* superficial structure, headers, hashes. */
p = le64toh(f->header->header_size);
- while (p != 0) {
+ for (;;) {
+ /* Early exit if there are no objects in the file, at all */
+ if (le64toh(f->header->tail_object_offset) == 0)
+ break;
+
if (show_progress)
draw_progress(scale_progress(0x7FFF, p, le64toh(f->header->tail_object_offset)), &last_usec);
@@ -901,9 +905,6 @@ int journal_file_verify(
goto fail;
}
- if (p == le64toh(f->header->tail_object_offset))
- found_last = true;
-
n_objects ++;
r = journal_file_object_verify(f, p, o);
@@ -1148,13 +1149,15 @@ int journal_file_verify(
n_weird ++;
}
- if (p == le64toh(f->header->tail_object_offset))
- p = 0;
- else
- p = p + ALIGN64(le64toh(o->object.size));
- }
+ if (p == le64toh(f->header->tail_object_offset)) {
+ found_last = true;
+ break;
+ }
- if (!found_last) {
+ p = p + ALIGN64(le64toh(o->object.size));
+ };
+
+ if (!found_last && le64toh(f->header->tail_object_offset) != 0) {
error(le64toh(f->header->tail_object_offset), "tail object pointer dead");
r = -EBADMSG;
goto fail;
@@ -1200,19 +1203,7 @@ int journal_file_verify(
goto fail;
}
- if (n_data_hash_tables != 1) {
- error(0, "missing data hash table");
- r = -EBADMSG;
- goto fail;
- }
-
- if (n_field_hash_tables != 1) {
- error(0, "missing field hash table");
- r = -EBADMSG;
- goto fail;
- }
-
- if (!found_main_entry_array) {
+ if (!found_main_entry_array && le64toh(f->header->entry_array_offset) != 0) {
error(0, "missing entry array");
r = -EBADMSG;
goto fail;