From: Yu Watanabe Date: Wed, 12 Oct 2022 06:59:43 +0000 (+0900) Subject: sd-journal: re-read object from cache X-Git-Tag: v252-rc2~55^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=231741d355fbbe544f6bf62d714f56a6c857fb6f;p=thirdparty%2Fsystemd.git sd-journal: re-read object from cache Fixes a bug introduced by 0e35afff1db475b46281fac75fa3fc2d7f26cae7. Replaces 3388a4b5820012b945d9925446764717afcdb5b0. --- diff --git a/src/libsystemd/sd-journal/journal-file.c b/src/libsystemd/sd-journal/journal-file.c index 13f891a6335..ca5f5c9fccf 100644 --- a/src/libsystemd/sd-journal/journal-file.c +++ b/src/libsystemd/sd-journal/journal-file.c @@ -4022,6 +4022,12 @@ int journal_file_copy_entry(JournalFile *from, JournalFile *to, Object *o, uint6 .object_offset = h, .hash = le64toh(u->data.hash), }; + + /* The above journal_file_data_payload() may clear or overwrite cached object. Hence, we need + * to re-read the object from the cache. */ + r = journal_file_move_to_object(from, OBJECT_ENTRY, p, &o); + if (r < 0) + return r; } r = journal_file_append_entry_internal(to, &ts, boot_id, xor_hash, items, n, NULL, NULL, NULL);