]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
coverity: #1425793
authorChristian Brauner <christian.brauner@ubuntu.com>
Fri, 15 Jun 2018 09:42:18 +0000 (11:42 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Mon, 10 Dec 2018 08:21:53 +0000 (09:21 +0100)
Unchecked return value

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/lxccontainer.c

index d5715b67d177f94f58b243933ae6bbe8e01b21e8..e5132eee00b85e8467cbf1b8d4f54fb45a27e417 100644 (file)
@@ -3118,14 +3118,20 @@ static bool add_rdepends(struct lxc_container *c, struct lxc_container *c0)
 bool should_default_to_snapshot(struct lxc_container *c0,
                                struct lxc_container *c1)
 {
+       int ret;
        size_t l0 = strlen(c0->config_path) + strlen(c0->name) + 2;
        size_t l1 = strlen(c1->config_path) + strlen(c1->name) + 2;
        char *p0 = alloca(l0 + 1);
        char *p1 = alloca(l1 + 1);
        char *rootfs = c0->lxc_conf->rootfs.path;
 
-       snprintf(p0, l0, "%s/%s", c0->config_path, c0->name);
-       snprintf(p1, l1, "%s/%s", c1->config_path, c1->name);
+       ret = snprintf(p0, l0, "%s/%s", c0->config_path, c0->name);
+       if (ret < 0 || ret >= l0)
+               return false;
+
+       ret = snprintf(p1, l1, "%s/%s", c1->config_path, c1->name);
+       if (ret < 0 || ret >= l1)
+               return false;
 
        if (!is_btrfs_fs(p0) || !is_btrfs_fs(p1))
                return false;