]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-journal: check validity of object type more strictly
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 1 May 2023 03:54:15 +0000 (12:54 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 1 May 2023 05:25:38 +0000 (14:25 +0900)
Otherwise, the object with invalid type may pass check_object_header()
when the requested type is OBJECT_UNUSED.

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

index 1ef755953777fb726da0d7dce313c0cf04340fa9..81bedfd7221c96ca7e2fe17464e60dd8f25d5f27 100644 (file)
@@ -791,10 +791,10 @@ static int check_object_header(JournalFile *f, Object *o, ObjectType type, uint6
                                        "Attempt to move to overly short object with size %"PRIu64": %" PRIu64,
                                        s, offset);
 
-        if (o->object.type <= OBJECT_UNUSED)
+        if (o->object.type <= OBJECT_UNUSED || o->object.type >= _OBJECT_TYPE_MAX)
                 return log_debug_errno(SYNTHETIC_ERRNO(EBADMSG),
-                                       "Attempt to move to object with invalid type: %" PRIu64,
-                                       offset);
+                                       "Attempt to move to object with invalid type (%u): %" PRIu64,
+                                       o->object.type, offset);
 
         if (type > OBJECT_UNUSED && o->object.type != type)
                 return log_debug_errno(SYNTHETIC_ERRNO(EBADMSG),