]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
cgfsng: do not go into infinite loop 2643/head
authorChristian Brauner <christian.brauner@ubuntu.com>
Wed, 26 Sep 2018 12:16:10 +0000 (14:16 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Wed, 26 Sep 2018 12:16:10 +0000 (14:16 +0200)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/cgroups/cgfsng.c

index 7388ad7675525a4a2fc112f9499c42b5b9f4cf71..e083ad6d61b80c038cdf09a01a61c0d36bbd3061 100644 (file)
@@ -1327,7 +1327,7 @@ __cgfsng_ops static inline bool cgfsng_monitor_create(struct cgroup_ops *ops,
                                                        struct lxc_handler *handler)
 {
        char *monitor_cgroup, *offset, *tmp;
-       int idx = 0;
+       int i, idx = 0;
        size_t len;
        bool bret = false;
        struct lxc_conf *conf = handler->conf;
@@ -1359,7 +1359,7 @@ __cgfsng_ops static inline bool cgfsng_monitor_create(struct cgroup_ops *ops,
                                goto on_error;
                }
 
-               for (int i = 0; ops->hierarchies[i]; i++) {
+               for (i = 0; ops->hierarchies[i]; i++) {
                        if (!monitor_create_path_for_hierarchy(ops->hierarchies[i], monitor_cgroup)) {
                                ERROR("Failed to create cgroup \"%s\"", ops->hierarchies[i]->monitor_full_path);
                                free(ops->hierarchies[i]->container_full_path);
@@ -1372,7 +1372,7 @@ __cgfsng_ops static inline bool cgfsng_monitor_create(struct cgroup_ops *ops,
                                break;
                        }
                }
-       } while (idx > 0 && idx < 1000);
+       } while (ops->hierarchies[i] && idx > 0 && idx < 1000);
 
        if (idx < 1000)
                bret = true;