summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-01-19 00:59:19 +0100
committerLennart Poettering <lennart@poettering.net>2013-01-19 01:02:30 +0100
commite884315e3d28df0d5f4e7d4590730e9760b8f447 (patch)
treeea794f1ccbc81cd45982d36ee1996ed28e265c7a /src/core
parentadf36dd0aec564a00a7445e328c3e27f44938629 (diff)
cgroup: additional validity checks for cgroup attribute names
Diffstat (limited to 'src/core')
-rw-r--r--src/core/unit.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/core/unit.c b/src/core/unit.c
index 83359e126b..6cf02365e9 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -2156,26 +2156,27 @@ int unit_add_cgroup_attribute(
_cleanup_free_ char *c = NULL;
CGroupAttribute *a;
+ int r;
assert(u);
assert(name);
assert(value);
if (!controller) {
- const char *dot;
-
- dot = strchr(name, '.');
- if (!dot)
+ r = cg_controller_from_attr(name, &c);
+ if (r < 0)
return -EINVAL;
- c = strndup(name, dot - name);
- if (!c)
- return -ENOMEM;
-
controller = c;
+ } else {
+ if (!filename_is_safe(name))
+ return -EINVAL;
+
+ if (!filename_is_safe(controller))
+ return -EINVAL;
}
- if (streq(controller, SYSTEMD_CGROUP_CONTROLLER))
+ if (!controller || streq(controller, SYSTEMD_CGROUP_CONTROLLER))
return -EINVAL;
a = cgroup_attribute_find_list(u->cgroup_attributes, controller, name);