summaryrefslogtreecommitdiffstats
path: root/src/libsystemd/sd-journal
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2023-05-06 17:16:30 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2023-05-06 17:26:49 +0200
commite562f131585fe6ae32b1f035ba48c1548d695259 (patch)
tree6f2af7cd4eab1fc4f907092873335caa95b1e968 /src/libsystemd/sd-journal
parentsd-journal: drop unnecessary initialization (diff)
downloadsystemd-e562f131585fe6ae32b1f035ba48c1548d695259.tar.xz
systemd-e562f131585fe6ae32b1f035ba48c1548d695259.zip
sd-journal: re-read entry array object
`test_object()` may call `journal_file_move_to_object()` and thus the `array` object may be invalidated.
Diffstat (limited to 'src/libsystemd/sd-journal')
-rw-r--r--src/libsystemd/sd-journal/journal-file.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/libsystemd/sd-journal/journal-file.c b/src/libsystemd/sd-journal/journal-file.c
index fb4b67c138..f594b3eecb 100644
--- a/src/libsystemd/sd-journal/journal-file.c
+++ b/src/libsystemd/sd-journal/journal-file.c
@@ -2975,8 +2975,16 @@ found:
if (subtract_one && t == 0 && i == 0)
return 0;
+ r = journal_file_move_to_object(f, OBJECT_ENTRY_ARRAY, a, &array);
+ if (r < 0)
+ return r;
+
+ p = journal_file_entry_array_item(f, array, 0);
+ if (p <= 0)
+ return -EBADMSG;
+
/* Let's cache this item for the next invocation */
- chain_cache_put(f->chain_cache, ci, first, a, journal_file_entry_array_item(f, array, 0), t, subtract_one ? (i > 0 ? i-1 : UINT64_MAX) : i);
+ chain_cache_put(f->chain_cache, ci, first, a, p, t, subtract_one ? (i > 0 ? i-1 : UINT64_MAX) : i);
if (subtract_one && i == 0)
p = last_p;