The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxc/pull/2124
This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) === if (file_exists(c->configfile) && !lxcapi_load_config(c, NULL)) goto err; if c->configfile is not exist, will donot call lxcapi_load_config. And not goto err, c->lxc_conf will not init. if user call size_t len = c->get_config_item(c, key, NULL, 0); will get a large length. ``` $ ./a.out befor len: 18446744073709551615 len: 18446744073709551615 ``` source code ``` int test_container(const char *name) { int ret = -1; struct lxc_container *c; char key[256] = "lxc.console.logfile"; /* Setup container struct */ c = lxc_container_new(name, NULL); if (!c) { fprintf(stderr, "Failed to setup lxc_container struct\n"); goto out; } size_t len = c->get_config_item(c, key, NULL, 0); printf("befor len: %lu\n", len); if (c->is_defined(c)) { fprintf(stderr, "Container already exists\n"); goto out; } len = c->get_config_item(c, key, NULL, 0); printf("len: %lu\n", len); out: lxc_container_put(c); return ret; } ``` Signed-off-by: duguhaotian <duguhaot...@gmail.com>
From 67d188bc0f959306a2512718a576d8b3249ccbda Mon Sep 17 00:00:00 2001 From: duguhaotian <duguhaot...@gmail.com> Date: Fri, 2 Feb 2018 20:02:44 +0800 Subject: [PATCH] [confile] wrong condition if (file_exists(c->configfile) && !lxcapi_load_config(c, NULL)) goto err; if c->configfile is not exist, will donot call lxcapi_load_config. And not goto err, c->lxc_conf will not init. if user call size_t len = c->get_config_item(c, key, NULL, 0); will get a large length. Signed-off-by: duguhaotian <duguhaot...@gmail.com> --- src/lxc/lxccontainer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c index 2a4bb51f3..27947fe1a 100644 --- a/src/lxc/lxccontainer.c +++ b/src/lxc/lxccontainer.c @@ -4675,7 +4675,7 @@ struct lxc_container *lxc_container_new(const char *name, const char *configpath goto err; } - if (file_exists(c->configfile) && !lxcapi_load_config(c, NULL)) { + if (!file_exists(c->configfile) && !lxcapi_load_config(c, NULL)) { fprintf(stderr, "Failed to load config for %s\n", name); goto err; }
_______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel