From: Yu Watanabe Date: Tue, 26 Sep 2023 16:35:31 +0000 (+0900) Subject: sd-journal: add missing 'error' handling X-Git-Tag: v255-rc1~374^2~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f85e79d3e57c0639f583d1e27c649ee561075d62;p=thirdparty%2Fsystemd.git 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. --- 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;