]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
lxcapi_snapshot: check that c is defined
authorSerge Hallyn <serge.hallyn@ubuntu.com>
Tue, 3 Jun 2014 18:16:03 +0000 (13:16 -0500)
committerStéphane Graber <stgraber@ubuntu.com>
Wed, 4 Jun 2014 14:58:36 +0000 (10:58 -0400)
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@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
src/lxc/lxccontainer.c

index eb3366b6f85c6b5a8f6955105e1a730747756ca5..62e38d7a24372adb300339cbd3de40e497b4945d 100644 (file)
@@ -2859,6 +2859,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)