From: Lennart Poettering Date: Wed, 12 Oct 2016 10:22:57 +0000 (+0200) Subject: journal: add an explicit check for uninitialized objects X-Git-Tag: v234~968^2~7 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1c69f0966a86e3c9ae0120e6222709414b68e186;p=platform%2Fupstream%2Fsystemd.git journal: add an explicit check for uninitialized objects Let's make dissecting of borked journal files more expressive: if we encounter an object whose first 8 bytes are all zeroes, then let's assume the object was simply never initialized, and say so. Previously, this would be detected as "overly short object", which is true too in a away, but it's a lot more helpful printing different debug options for the case where the size is not initialized at all and where the size is initialized to some bogus value. No function behaviour change, only a different log messages for both cases. --- diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c index f598582..3f1afda 100644 --- a/src/journal/journal-file.c +++ b/src/journal/journal-file.c @@ -765,6 +765,10 @@ int journal_file_move_to_object(JournalFile *f, ObjectType type, uint64_t offset o = (Object*) t; s = le64toh(o->object.size); + if (s == 0) { + log_debug("Attempt to move to uninitialized object: %" PRIu64, offset); + return -EBADMSG; + } if (s < sizeof(ObjectHeader)) { log_debug("Attempt to move to overly short object: %" PRIu64, offset); return -EBADMSG;