Skip to content

Commit 3cee294

Browse files
YHNdnzjbluca
authored andcommitted
core: validate input cgroup path more prudently
(cherry picked from commit efa6ba2)
1 parent 80acea4 commit 3cee294

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

src/core/dbus-manager.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,12 @@ static int method_get_unit_by_control_group(sd_bus_message *message, void *userd
652652
if (r < 0)
653653
return r;
654654

655+
if (!path_is_absolute(cgroup))
656+
return sd_bus_error_setf(reterr_error, SD_BUS_ERROR_INVALID_ARGS, "Control group path is not absolute: %s", cgroup);
657+
658+
if (!path_is_normalized(cgroup))
659+
return sd_bus_error_setf(reterr_error, SD_BUS_ERROR_INVALID_ARGS, "Control group path is not normalized: %s", cgroup);
660+
655661
u = manager_get_unit_by_cgroup(m, cgroup);
656662
if (!u)
657663
return sd_bus_error_setf(reterr_error, BUS_ERROR_NO_SUCH_UNIT,

src/core/varlink-unit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ static int lookup_unit_by_parameters(sd_varlink *link, Manager *manager, UnitLoo
467467
}
468468

469469
if (p->cgroup) {
470-
if (!path_is_safe(p->cgroup))
470+
if (!path_is_absolute(p->cgroup) || !path_is_normalized(p->cgroup))
471471
return sd_varlink_error_invalid_parameter_name(link, "cgroup");
472472

473473
Unit *cgroup_unit = manager_get_unit_by_cgroup(manager, p->cgroup);

0 commit comments

Comments
 (0)