Commit cd704e80 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

cgroups: Make sure the cgroup formatted correctly

In case if something is broken in the kernel and
we get a format corrupted -- simply exit out with
error instead of strlen'ing nil string.

Also while at it -- add a comment about format.
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Acked-by: 's avatarTycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 0f178a1f
...@@ -1530,8 +1530,20 @@ int parse_task_cgroup(int pid, struct list_head *retl, unsigned int *n) ...@@ -1530,8 +1530,20 @@ int parse_task_cgroup(int pid, struct list_head *retl, unsigned int *n)
if (!ncc) if (!ncc)
goto err; goto err;
/*
* Typical output (':' is a separator here)
*
* 4:cpu,cpuacct:/
* 3:cpuset:/
* 2:name=systemd:/user.slice/user-1000.slice/session-1.scope
*/
name = strchr(buf, ':') + 1; name = strchr(buf, ':') + 1;
path = strchr(name, ':'); path = strchr(name, ':');
if (!name || !path) {
pr_err("Failed parsing cgroup %s\n", buf);
xfree(ncc);
goto err;
}
e = strchr(name, '\n'); e = strchr(name, '\n');
*path++ = '\0'; *path++ = '\0';
if (e) if (e)
......
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