From: Christian Brauner Date: Sat, 17 Feb 2018 18:29:02 +0000 (+0100) Subject: cgfsng: cgfsng_enter() X-Git-Tag: lxc-3.0.0.beta1~22^2~45 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=08768001650cd132ca3151721e9a0ad59320b33e;p=thirdparty%2Flxc.git cgfsng: cgfsng_enter() Signed-off-by: Christian Brauner --- diff --git a/src/lxc/cgroups/cgfsng.c b/src/lxc/cgroups/cgfsng.c index 9e8a1ca31..ba75ebe75 100644 --- a/src/lxc/cgroups/cgfsng.c +++ b/src/lxc/cgroups/cgfsng.c @@ -1844,18 +1844,22 @@ out_free: static bool cgfsng_enter(void *hdata, pid_t pid) { - char pidstr[25]; int i, len; + char pidstr[25]; len = snprintf(pidstr, 25, "%d", pid); - if (len < 0 || len > 25) + if (len < 0 || len >= 25) return false; for (i = 0; hierarchies[i]; i++) { - char *fullpath = must_make_path(hierarchies[i]->fullcgpath, - "cgroup.procs", NULL); - if (lxc_write_to_file(fullpath, pidstr, len, false) != 0) { - SYSERROR("Failed to enter %s", fullpath); + int ret; + char *fullpath; + + fullpath = must_make_path(hierarchies[i]->fullcgpath, + "cgroup.procs", NULL); + ret = lxc_write_to_file(fullpath, pidstr, len, false); + if (ret != 0) { + SYSERROR("Failed to enter cgroup \"%s\"", fullpath); free(fullpath); return false; }