From: Christian Brauner Date: Wed, 26 Sep 2018 12:16:10 +0000 (+0200) Subject: cgfsng: do not go into infinite loop X-Git-Tag: lxc-3.1.0~81^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ebc10afe213872d92c3d4641e34e6bd3c6d826be;p=thirdparty%2Flxc.git cgfsng: do not go into infinite loop Signed-off-by: Christian Brauner --- diff --git a/src/lxc/cgroups/cgfsng.c b/src/lxc/cgroups/cgfsng.c index 7388ad767..e083ad6d6 100644 --- a/src/lxc/cgroups/cgfsng.c +++ b/src/lxc/cgroups/cgfsng.c @@ -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;