X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fjournal%2Fjournal-file.c;h=3bb1e90fb324b9f86b3a8c76c87cf641a480fa0e;hp=ff439f24743ea134c6aee802839ed56d3ae51a0a;hb=b7c9ae91d111b3e89d1ffc00e08f9ed97a8ff5db;hpb=0284adc6a60ce0af1107cb0b50041a65d731f39e diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c index ff439f247..3bb1e90fb 100644 --- a/src/journal/journal-file.c +++ b/src/journal/journal-file.c @@ -96,8 +96,12 @@ void journal_file_close(JournalFile *f) { #endif #ifdef HAVE_GCRYPT - if (f->fsprg_header) - munmap(f->fsprg_header, PAGE_ALIGN(f->fsprg_size)); + if (f->fsprg_file) + munmap(f->fsprg_file, PAGE_ALIGN(f->fsprg_file_size)); + else if (f->fsprg_state) + free(f->fsprg_state); + + free(f->fsprg_seed); if (f->hmac) gcry_md_close(f->hmac); @@ -319,23 +323,6 @@ static int journal_file_move_to(JournalFile *f, int context, uint64_t offset, ui return mmap_cache_get(f->mmap, f->fd, f->prot, context, offset, size, ret); } -static bool verify_hash(Object *o) { - uint64_t h1, h2; - - assert(o); - - if (o->object.type == OBJECT_DATA && !(o->object.flags & OBJECT_COMPRESSED)) { - h1 = le64toh(o->data.hash); - h2 = hash64(o->data.payload, le64toh(o->object.size) - offsetof(Object, data.payload)); - } else if (o->object.type == OBJECT_FIELD) { - h1 = le64toh(o->field.hash); - h2 = hash64(o->field.payload, le64toh(o->object.size) - offsetof(Object, field.payload)); - } else - return true; - - return h1 == h2; -} - static uint64_t minimum_header_size(Object *o) { static uint64_t table[] = { @@ -394,9 +381,6 @@ int journal_file_move_to_object(JournalFile *f, int type, uint64_t offset, Objec o = (Object*) t; } - if (!verify_hash(o)) - return -EBADMSG; - *ret = o; return 0; } @@ -859,6 +843,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; @@ -2154,7 +2141,7 @@ int journal_file_open_reliably( bool compress, bool authenticate, JournalMetrics *metrics, - MMapCache *mmap, + MMapCache *mmap_cache, JournalFile *template, JournalFile **ret) { @@ -2162,7 +2149,8 @@ int journal_file_open_reliably( size_t l; char *p; - r = journal_file_open(fname, flags, mode, compress, authenticate, metrics, mmap, template, ret); + r = journal_file_open(fname, flags, mode, compress, authenticate, + metrics, mmap_cache, template, ret); if (r != -EBADMSG && /* corrupted */ r != -ENODATA && /* truncated */ r != -EHOSTDOWN && /* other machine */ @@ -2196,7 +2184,8 @@ int journal_file_open_reliably( log_warning("File %s corrupted or uncleanly shut down, renaming and replacing.", fname); - return journal_file_open(fname, flags, mode, compress, authenticate, metrics, mmap, template, ret); + return journal_file_open(fname, flags, mode, compress, authenticate, + metrics, mmap_cache, template, ret); }