[lxc-devel] [lxc/master] [confile] wrong condition

duguhaotian on Github lxc-bot at linuxcontainers.org
Fri Feb 2 12:08:24 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 1523 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180202/478d5b1c/attachment.bin>
-------------- next part --------------
From 67d188bc0f959306a2512718a576d8b3249ccbda Mon Sep 17 00:00:00 2001
From: duguhaotian <duguhaotian at 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 <duguhaotian at 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;
 	}


More information about the lxc-devel mailing list