cgroup-util: be more strict when processing slice unit names

This commit is contained in:
Lennart Poettering
2015-05-05 15:06:33 -07:00
parent 32fea77178
commit e66e5b612a
2 changed files with 8 additions and 2 deletions
+7 -1
View File
@@ -1663,11 +1663,17 @@ int cg_slice_to_path(const char *unit, char **ret) {
return -ENOMEM;
dash = strchr(p, '-');
/* Don't allow initial dashes */
if (dash == p)
return -EINVAL;
while (dash) {
_cleanup_free_ char *escaped = NULL;
char n[dash - p + sizeof(".slice")];
if (isempty(dash + 1))
/* Don't allow trailing or double dashes */
if (dash[1] == 0 || dash[1] == '-')
return -EINVAL;
strcpy(stpncpy(n, p, dash - p), ".slice");