]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
journal-file: when iterating through a partly corruped journal file, treat error...
authorLennart Poettering <lennart@poettering.net>
Tue, 26 Apr 2016 09:38:39 +0000 (11:38 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 26 Apr 2016 10:00:49 +0000 (12:00 +0200)
When we linearly iterate through a corrupted journal file, and we encounter a
read error, don't consider this fatal, but merely as EOF condition (and log
about it).

src/journal/journal-file.c

index e13ae05990b8589bd3e02c0f2e7f322f73e8263b..c97b3f98828f7a63cf8d610beed7eed98cc3a8bd 100644 (file)
@@ -2469,12 +2469,18 @@ int journal_file_next_entry(
                               le64toh(f->header->entry_array_offset),
                               i,
                               ret, &ofs);
+        if (r == -EBADMSG && direction == DIRECTION_DOWN) {
+                /* Special case: when we iterate throught the journal file linearly, and hit an entry we can't read,
+                 * consider this the end of the journal file. */
+                log_debug_errno(r, "Encountered entry we can't read while iterating through journal file. Considering this the end of the file.");
+                return 0;
+        }
         if (r <= 0)
                 return r;
 
         if (p > 0 &&
             (direction == DIRECTION_DOWN ? ofs <= p : ofs >= p)) {
-                log_debug("%s: entry array corrupted at entry %"PRIu64, f->path, i);
+                log_debug("%s: entry array corrupted at entry %" PRIu64, f->path, i);
                 return -EBADMSG;
         }