From 210cb8d690cf585b7cd162efbdc563a5ae6921ff Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Sat, 6 May 2023 14:27:02 +0900 Subject: [PATCH] core/unit: check the validity of unit type with activation_details_vtable Follow-up for 24e91e08f8958241195f97472353adef94884b33. --- src/core/unit.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/core/unit.c b/src/core/unit.c index 4e9ae6148f3..d275adb9b0f 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -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);