summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-04-30 12:33:35 +0200
committerLennart Poettering <lennart@poettering.net>2015-04-30 12:33:35 +0200
commitc96cc5822c165e86be78ed96dac6573986032fab (patch)
tree49431ec74b6c53333036fec9909bbc394f0ee85f /src/shared
parent6bd68a1aa2c4a6250308882caf1025100908b15f (diff)
core: catch some special cases in cg_slice_to_path()
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/cgroup-util.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/shared/cgroup-util.c b/src/shared/cgroup-util.c
index dbf7942024..1306cc197a 100644
--- a/src/shared/cgroup-util.c
+++ b/src/shared/cgroup-util.c
@@ -1642,6 +1642,16 @@ int cg_slice_to_path(const char *unit, char **ret) {
assert(unit);
assert(ret);
+ if (streq(unit, "-.slice")) {
+ char *x;
+
+ x = strdup("");
+ if (!x)
+ return -ENOMEM;
+ *ret = x;
+ return 0;
+ }
+
if (!unit_name_is_valid(unit, TEMPLATE_INVALID))
return -EINVAL;
@@ -1657,8 +1667,10 @@ int cg_slice_to_path(const char *unit, char **ret) {
_cleanup_free_ char *escaped = NULL;
char n[dash - p + sizeof(".slice")];
- strcpy(stpncpy(n, p, dash - p), ".slice");
+ if (isempty(dash + 1))
+ return -EINVAL;
+ strcpy(stpncpy(n, p, dash - p), ".slice");
if (!unit_name_is_valid(n, TEMPLATE_INVALID))
return -EINVAL;