From: Serge Hallyn Date: Tue, 3 Jun 2014 18:16:03 +0000 (-0500) Subject: lxcapi_snapshot: check that c is defined X-Git-Tag: lxc-1.1.0.alpha1~63 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=840f05df;p=thirdparty%2Flxc.git lxcapi_snapshot: check that c is defined 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 Acked-by: Stéphane Graber --- diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c index ac6de6233..5cedb27a7 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)