]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-journal: ignore failure in testing cached corrupted entry
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 29 Nov 2023 21:46:21 +0000 (06:46 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 1 Dec 2023 00:27:38 +0000 (09:27 +0900)
Let's consider the case that the 1st entry in an array is broken, but
n-th entry is valid. Then, if generic_array_get() is called to read
n-th object, the offset of the broken entry is cached by the function.
If generic_array_bisect() is followed, even if the matching entry is
valid, it always fail with -EBADMSG or friends, as the function test the
cached entry at the beginnning. Let's ignore the failure in testing the
cached entry.

src/libsystemd/sd-journal/journal-file.c

index f72498c2e71bc1ba9455acfb459aa2dd38d919f6..e402cb3b26f354a49b01e35070aeab6744a18876 100644 (file)
@@ -3006,10 +3006,11 @@ static int generic_array_bisect(
                  * check that first. */
 
                 r = test_object(f, ci->begin, needle);
-                if (r < 0)
+                if (IN_SET(r, -EBADMSG, -EADDRNOTAVAIL))
+                        log_debug_errno(r, "Cached entry is corrupted, ignoring: %m");
+                else if (r < 0)
                         return r;
-
-                if (r == TEST_LEFT) {
+                else if (r == TEST_LEFT) {
                         /* OK, what we are looking for is right of the begin of this EntryArray, so let's
                          * jump straight to previously cached array in the chain */