]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
coverity: #1425767
authorChristian Brauner <christian.brauner@ubuntu.com>
Thu, 14 Jun 2018 20:10:26 +0000 (22:10 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Thu, 14 Jun 2018 20:36:45 +0000 (22:36 +0200)
Unchecked return value

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

index be07aeb6f13e0062e0c9742df86ec01fa67e6fee..f22c417470b2c65129c6553b284e9a5a4b3b8620 100644 (file)
@@ -659,7 +659,7 @@ static void free_btrfs_tree(struct my_btrfs_tree *tree)
 static bool do_remove_btrfs_children(struct my_btrfs_tree *tree, u64 root_id,
                                     const char *path)
 {
-       int i;
+       int i, ret;
        char *newpath;
        size_t len;
 
@@ -675,7 +675,11 @@ static bool do_remove_btrfs_children(struct my_btrfs_tree *tree, u64 root_id,
                                ERROR("Out of memory");
                                return false;
                        }
-                       snprintf(newpath, len, "%s/%s", path, tree->nodes[i].dirname);
+                       ret = snprintf(newpath, len, "%s/%s", path, tree->nodes[i].dirname);
+                       if (ret < 0 || ret >= len) {
+                               free(newpath);
+                               return false;
+                       }
                        if (!do_remove_btrfs_children(tree, tree->nodes[i].objid, newpath)) {
                                ERROR("Failed to prune %s\n", tree->nodes[i].name);
                                free(newpath);