]> 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>
Mon, 10 Dec 2018 08:18:10 +0000 (09:18 +0100)
Unchecked return value

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

index 8b5274bedd58ea555f07ec2d2acc290bb9eadb34..511e6a03fb06e13947dd397bde08c15009225c09 100644 (file)
@@ -578,7 +578,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;
 
@@ -594,7 +594,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);