summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2022-06-28 21:52:54 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2022-06-28 21:54:05 +0200
commitb8478c14c7367c3ec5d47d2680a3390b0dedecb1 (patch)
treea684ddd22ee6e627b3f6f29ab7c72322b019cc16 /src
parentsd-journal: also check object header before verifying object data (diff)
downloadsystemd-b8478c14c7367c3ec5d47d2680a3390b0dedecb1.tar.xz
systemd-b8478c14c7367c3ec5d47d2680a3390b0dedecb1.zip
sd-journal: data object may be invalid after data_object_in_hash_table()
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.
Diffstat (limited to 'src')
-rw-r--r--src/libsystemd/sd-journal/journal-verify.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/libsystemd/sd-journal/journal-verify.c b/src/libsystemd/sd-journal/journal-verify.c
index 1495450394..03c79cea13 100644
--- a/src/libsystemd/sd-journal/journal-verify.c
+++ b/src/libsystemd/sd-journal/journal-verify.c
@@ -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;