[CRIU] [PATCH] cg: Fix separator search in parse_task_cgroup

Cyrill Gorcunov gorcunov at openvz.org
Tue Sep 16 05:03:13 PDT 2014


If there is no separator in first place we should
avoid implicit + 1 which make @name = 1 in worst case.

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 proc_parse.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/proc_parse.c b/proc_parse.c
index e311f40a4f88..1d9bc7b72cd9 100644
--- a/proc_parse.c
+++ b/proc_parse.c
@@ -1706,9 +1706,9 @@ int parse_task_cgroup(int pid, struct list_head *retl, unsigned int *n)
 		 * 3:cpuset:/
 		 * 2:name=systemd:/user.slice/user-1000.slice/session-1.scope
 		 */
-		name = strchr(buf, ':') + 1;
+		name = strchr(buf, ':');
 		if (name)
-			path = strchr(name, ':');
+			path = strchr(++name, ':');
 		if (!name || !path) {
 			pr_err("Failed parsing cgroup %s\n", buf);
 			xfree(ncc);
-- 
1.9.3



More information about the CRIU mailing list