From: Yu Watanabe Date: Wed, 29 Nov 2023 21:46:21 +0000 (+0900) Subject: sd-journal: ignore failure in testing cached corrupted entry X-Git-Tag: v255-rc4~16^2~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5dca908a9a23247b1428fcfe29e7478575ddf9c4;p=thirdparty%2Fsystemd.git sd-journal: ignore failure in testing cached corrupted entry 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. --- diff --git a/src/libsystemd/sd-journal/journal-file.c b/src/libsystemd/sd-journal/journal-file.c index f72498c2e71..e402cb3b26f 100644 --- a/src/libsystemd/sd-journal/journal-file.c +++ b/src/libsystemd/sd-journal/journal-file.c @@ -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 */