]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core/unit: check the validity of unit type with activation_details_vtable
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 6 May 2023 05:27:02 +0000 (14:27 +0900)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 8 May 2023 07:49:55 +0000 (09:49 +0200)
Follow-up for 24e91e08f8958241195f97472353adef94884b33.

src/core/unit.c

index 4e9ae6148f396b08c4f137475cdfdd8b34d4e524..d275adb9b0f51aa163ea3acdb9f9c537e03b385a 100644 (file)
@@ -6162,9 +6162,11 @@ int activation_details_deserialize(const char *key, const char *value, Activatio
                         return -EINVAL;
 
                 t = unit_type_from_string(value);
-                /* The activation details vtable has defined ops only for path
-                 * and timer units */
-                if (!IN_SET(t, UNIT_PATH, UNIT_TIMER))
+                if (t < 0)
+                        return t;
+
+                /* The activation details vtable has defined ops only for path and timer units */
+                if (!activation_details_vtable[t])
                         return -EINVAL;
 
                 *details = malloc0(activation_details_vtable[t]->object_size);