core/unit: check the validity of unit type with activation_details_vtable

Follow-up for 24e91e08f8.
This commit is contained in:
Yu Watanabe 2023-05-06 14:27:02 +09:00 committed by Daan De Meyer
parent d2132d3d8d
commit 210cb8d690

View 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);