core: validate input cgroup path more prudently
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user