]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
cgfsng: cgfsng_enter()
authorChristian Brauner <christian.brauner@ubuntu.com>
Sat, 17 Feb 2018 18:29:02 +0000 (19:29 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Wed, 21 Feb 2018 14:48:39 +0000 (15:48 +0100)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/cgroups/cgfsng.c

index 081a063113ac2276277c4eb2c4322ce7241fe564..9d9ba5adb5fcc48fdfa3af428602f8a674488252 100644 (file)
@@ -1822,18 +1822,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;
                }