From b7aeda9691f782e1d13b6ab57bd6c27d5dc4cc87 Mon Sep 17 00:00:00 2001 From: Christian Brauner Date: Wed, 3 Feb 2021 00:00:50 +0100 Subject: [PATCH] cgroups: improve parameter vetting Signed-off-by: Christian Brauner --- src/lxc/cgroups/cgfsng.c | 5 +++-- src/lxc/lxccontainer.c | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/lxc/cgroups/cgfsng.c b/src/lxc/cgroups/cgfsng.c index 766ed3677..0276411ab 100644 --- a/src/lxc/cgroups/cgfsng.c +++ b/src/lxc/cgroups/cgfsng.c @@ -2622,8 +2622,9 @@ __cgfsng_ops static int cgfsng_set(struct cgroup_ops *ops, struct hierarchy *h; int ret = -1; - if (!ops || !key || !value || !name || !lxcpath) - return ret_errno(ENOENT); + if (!ops || is_empty_string(key) || is_empty_string(value) || + is_empty_string(name) || is_empty_string(lxcpath)) + return ret_errno(EINVAL); controller = must_copy_string(key); p = strchr(controller, '.'); diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c index 63cf63628..c8d93a30a 100644 --- a/src/lxc/lxccontainer.c +++ b/src/lxc/lxccontainer.c @@ -3300,7 +3300,7 @@ static bool do_lxcapi_set_cgroup_item(struct lxc_container *c, const char *subsy if (!cgroup_ops) return false; - ret = cgroup_ops->set(cgroup_ops, subsys, value, c->name, c->config_path) == 0; + ret = cgroup_ops->set(cgroup_ops, subsys, value, c->name, c->config_path); } return ret == 0; -- 2.47.2