From f85e79d3e57c0639f583d1e27c649ee561075d62 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 27 Sep 2023 01:35:31 +0900 Subject: [PATCH] sd-journal: add missing 'error' handling When we reach an empty array, there are at least two possibilities: - journal file is corrupted, - invalid index is requested. We cannot distinguish them here, let's simply return earlier. --- src/libsystemd/sd-journal/journal-file.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libsystemd/sd-journal/journal-file.c b/src/libsystemd/sd-journal/journal-file.c index 474d7b1d27d..99528680163 100644 --- a/src/libsystemd/sd-journal/journal-file.c +++ b/src/libsystemd/sd-journal/journal-file.c @@ -2788,6 +2788,9 @@ static int generic_array_get( return r; k = journal_file_entry_array_n_items(f, o); + if (k == 0) + return 0; + if (i < k) break;