]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
journal: Skip corrupt Data objects in sd_journal_get_data() 21420/head
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 17 Nov 2021 16:46:29 +0000 (16:46 +0000)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 18 Nov 2021 21:43:17 +0000 (21:43 +0000)
Similar to the change we made for sd_journal_enumerate_data(), let's
skip corrupt entry items and data objects in sd_journal_get_data().

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

index e440d3c560c6f72bd867928db78c510513c3e09d..738c6974687e03d475daf57e66ed166b662ae78e 100644 (file)
@@ -2306,11 +2306,17 @@ _public_ int sd_journal_get_data(sd_journal *j, const char *field, const void **
                 p = le64toh(o->entry.items[i].object_offset);
                 le_hash = o->entry.items[i].hash;
                 r = journal_file_move_to_object(f, OBJECT_DATA, p, &d);
+                if (r == -EBADMSG) {
+                        log_debug("Entry item %"PRIu64" data object is bad, skipping over it.", i);
+                        continue;
+                }
                 if (r < 0)
                         return r;
 
-                if (le_hash != d->data.hash)
-                        return -EBADMSG;
+                if (le_hash != d->data.hash) {
+                        log_debug("Entry item %"PRIu64" hash is bad, skipping over it.", i);
+                        continue;
+                }
 
                 l = le64toh(d->object.size) - offsetof(Object, data.payload);