summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2021-06-08 23:17:53 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2021-07-09 19:09:25 +0200
commitd804bcadcb448879f31c32363970d9b70b742b9a (patch)
treee9f8def94ee810c418733b421c279e506116a21c
parent84e1819ec104a168f7904134b6212669133c955f (diff)
downloadsystemd-d804bcadcb448879f31c32363970d9b70b742b9a.tar.gz
journal: don't try to reuse already calculated hash between files with keyed hash feature
When suppressing duplicate fields between files we so far tried to reuse the already known hash value of the data fields between files. This was fine as long as we used the same hash function everywhere. However, since addition of the keyed hash feature for journal files this doesn't work anymore, since the hashes will be different for different files. Fixes: #19172 (cherry picked from commit 2e1a8a5dab8b5519c079c9bed54fc682aa4095b0)
-rw-r--r--src/libsystemd/sd-journal/sd-journal.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/libsystemd/sd-journal/sd-journal.c b/src/libsystemd/sd-journal/sd-journal.c
index ffc7af4087..e43947a7c8 100644
--- a/src/libsystemd/sd-journal/sd-journal.c
+++ b/src/libsystemd/sd-journal/sd-journal.c
@@ -2984,7 +2984,13 @@ _public_ int sd_journal_enumerate_unique(sd_journal *j, const void **data, size_
if (JOURNAL_HEADER_CONTAINS(of->header, n_fields) && le64toh(of->header->n_fields) <= 0)
continue;
- r = journal_file_find_data_object_with_hash(of, odata, ol, le64toh(o->data.hash), NULL, NULL);
+ /* We can reuse the hash from our current file only on old-style journal files
+ * without keyed hashes. On new-style files we have to calculate the hash anew, to
+ * take the per-file hash seed into consideration. */
+ if (!JOURNAL_HEADER_KEYED_HASH(j->unique_file->header) && !JOURNAL_HEADER_KEYED_HASH(of->header))
+ r = journal_file_find_data_object_with_hash(of, odata, ol, le64toh(o->data.hash), NULL, NULL);
+ else
+ r = journal_file_find_data_object(of, odata, ol, NULL, NULL);
if (r < 0)
return r;
if (r > 0) {