]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-journal: data object may be invalid after data_object_in_hash_table() 23836/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 28 Jun 2022 19:52:54 +0000 (04:52 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 28 Jun 2022 19:54:05 +0000 (04:54 +0900)
Fixes a bug introduced by 578cd1855b73d2710ae14a8d77c4fac1d8ea7f48.

The function `data_object_in_hash_table()` calls
`journal_file_move_to_object()` with `OBJECT_DATA`. Hence,
previously obtained pointer to a data object may be now invalid.

Fixes #23794.

src/libsystemd/sd-journal/journal-verify.c

index 149545039491d6f1defba379fa2f9d9eb1ed4541..03c79cea1361f7a56883f333435bc0d434ee4983 100644 (file)
@@ -670,6 +670,11 @@ static int verify_entry(
                         return -EBADMSG;
                 }
 
+                /* Pointer might have moved, reposition */
+                r = journal_file_move_to_object(f, OBJECT_DATA, q, &u);
+                if (r < 0)
+                        return r;
+
                 r = journal_file_move_to_entry_by_offset_for_data(f, u, p, DIRECTION_DOWN, NULL, NULL);
                 if (r < 0)
                         return r;