summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2012-08-18 00:40:48 +0200
committerLennart Poettering <lennart@poettering.net>2012-08-18 00:41:06 +0200
commit97147f8c1f63234470a7062d2ed0f999c0996d42 (patch)
tree7121f95789e96f573826947c0657ccba047ff6f8 /src
parentb72631e59c1b9f62bcfaf1ce3f7e72e4a3beee89 (diff)
downloadsystemd-97147f8c1f63234470a7062d2ed0f999c0996d42.tar.gz
journal: refuse verification of files with unknown flags
Diffstat (limited to 'src')
-rw-r--r--src/journal/journal-verify.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/src/journal/journal-verify.c b/src/journal/journal-verify.c
index f66b23556b..e3bd8ffbd7 100644
--- a/src/journal/journal-verify.c
+++ b/src/journal/journal-verify.c
@@ -692,6 +692,8 @@ int journal_file_verify(
char data_path[] = "/var/tmp/journal-data-XXXXXX",
entry_path[] = "/var/tmp/journal-entry-XXXXXX",
entry_array_path[] = "/var/tmp/journal-entry-array-XXXXXX";
+ unsigned i;
+ bool found_last;
assert(f);
@@ -728,6 +730,24 @@ int journal_file_verify(
}
unlink(entry_array_path);
+#ifdef HAVE_GCRYPT
+ if ((le32toh(f->header->compatible_flags) & ~HEADER_COMPATIBLE_SEALED) != 0)
+#else
+ if (f->header->compatible_flags != 0)
+#endif
+ {
+ log_error("Cannot verify file with unknown extensions.");
+ r = -ENOTSUP;
+ goto fail;
+ }
+
+ for (i = 0; i < sizeof(f->header->reserved); i++)
+ if (f->header->reserved[i] != 0) {
+ log_error("Reserved field in non-zero.");
+ r = -EBADMSG;
+ goto fail;
+ }
+
/* First iteration: we go through all objects, verify the
* superficial structure, headers, hashes. */
@@ -742,12 +762,15 @@ int journal_file_verify(
goto fail;
}
- if (le64toh(f->header->tail_object_offset) < p) {
+ if (p > le64toh(f->header->tail_object_offset)) {
log_error("Invalid tail object pointer");
r = -EBADMSG;
goto fail;
}
+ if (p == le64toh(f->header->tail_object_offset))
+ found_last = true;
+
n_objects ++;
r = journal_file_object_verify(f, o);
@@ -983,6 +1006,12 @@ int journal_file_verify(
p = p + ALIGN64(le64toh(o->object.size));
}
+ if (!found_last) {
+ log_error("Tail object pointer dead");
+ r = -EBADMSG;
+ goto fail;
+ }
+
if (n_objects != le64toh(f->header->n_objects)) {
log_error("Object number mismatch");
r = -EBADMSG;