core: validate input cgroup path more prudently

This commit is contained in:
Mike Yuan
2026-02-26 14:23:25 +01:00
parent 42aee39107
commit efa6ba2ab6
2 changed files with 7 additions and 1 deletions
+6
View File
@@ -652,6 +652,12 @@ static int method_get_unit_by_control_group(sd_bus_message *message, void *userd
if (r < 0)
return r;
if (!path_is_absolute(cgroup))
return sd_bus_error_setf(reterr_error, SD_BUS_ERROR_INVALID_ARGS, "Control group path is not absolute: %s", cgroup);
if (!path_is_normalized(cgroup))
return sd_bus_error_setf(reterr_error, SD_BUS_ERROR_INVALID_ARGS, "Control group path is not normalized: %s", cgroup);
u = manager_get_unit_by_cgroup(m, cgroup);
if (!u)
return sd_bus_error_setf(reterr_error, BUS_ERROR_NO_SUCH_UNIT,
+1 -1
View File
@@ -457,7 +457,7 @@ static int lookup_unit_by_parameters(
}
if (p->cgroup) {
if (!path_is_safe(p->cgroup))
if (!path_is_absolute(p->cgroup) || !path_is_normalized(p->cgroup))
return sd_varlink_error_invalid_parameter_name(link, "cgroup");
Unit *cgroup_unit = manager_get_unit_by_cgroup(manager, p->cgroup);