Commit a0ab5665 authored by Lennart Poettering's avatar Lennart Poettering

cgroup: when escaping a cgroup object name, also escape names that start with a dot

parent 4641a16b
......@@ -1527,7 +1527,12 @@ char *cg_escape(const char *p) {
/* The return value of this function (unlike cg_unescape())
* needs free()! */
if (p[0] == '_' || streq(p, "notify_on_release") || streq(p, "release_agent") || streq(p, "tasks"))
if (p[0] == 0 ||
p[0] == '_' ||
p[0] == '.' ||
streq(p, "notify_on_release") ||
streq(p, "release_agent") ||
streq(p, "tasks"))
need_prefix = true;
else {
const char *dot;
......
......@@ -146,11 +146,15 @@ static void test_escape_one(const char *s, const char *r) {
static void test_escape(void) {
test_escape_one("foobar", "foobar");
test_escape_one(".foobar", "_.foobar");
test_escape_one("foobar.service", "foobar.service");
test_escape_one("cgroup.service", "_cgroup.service");
test_escape_one("cpu.service", "_cpu.service");
test_escape_one("tasks", "_tasks");
test_escape_one("_foobar", "__foobar");
test_escape_one("", "_");
test_escape_one("_", "__");
test_escape_one(".", "_.");
}
static void test_controller_is_valid(void) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment