[lxc-devel] [PATCH 1/1] lxcapi_snapshot: check that c is defined

Serge Hallyn serge.hallyn at ubuntu.com
Tue Jun 3 18:16:03 UTC 2014


before using it, like the other snapshot api methods do.

This will need to go into stable-1.0 as well.

Signed-off-by: Serge Hallyn <serge.hallyn at ubuntu.com>
---
 src/lxc/lxccontainer.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c
index ac6de62..5cedb27 100644
--- a/src/lxc/lxccontainer.c
+++ b/src/lxc/lxccontainer.c
@@ -2852,6 +2852,9 @@ static int lxcapi_snapshot(struct lxc_container *c, const char *commentfile)
 	struct lxc_container *c2;
 	char snappath[MAXPATHLEN], newname[20];
 
+	if (!c || !lxcapi_is_defined(c))
+		return -1;
+
 	// /var/lib/lxc -> /var/lib/lxcsnaps \0
 	ret = snprintf(snappath, MAXPATHLEN, "%ssnaps/%s", c->config_path, c->name);
 	if (ret < 0 || ret >= MAXPATHLEN)
-- 
2.0.0



More information about the lxc-devel mailing list