]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-journal: add missing 'error' handling
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 26 Sep 2023 16:35:31 +0000 (01:35 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 30 Sep 2023 11:10:15 +0000 (20:10 +0900)
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

index 474d7b1d27d4c0fb49591dfa835119780c4c5dd5..99528680163a277b5f086d871b0c1f3e924ac77f 100644 (file)
@@ -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;