From: Christian Brauner Date: Thu, 14 Jun 2018 20:10:26 +0000 (+0200) Subject: coverity: #1425767 X-Git-Tag: lxc-2.0.10~93 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=77149cc08884d38eede70496b4b705f2d507334a;p=thirdparty%2Flxc.git coverity: #1425767 Unchecked return value Signed-off-by: Christian Brauner --- diff --git a/src/lxc/storage/btrfs.c b/src/lxc/storage/btrfs.c index 8b5274bed..511e6a03f 100644 --- a/src/lxc/storage/btrfs.c +++ b/src/lxc/storage/btrfs.c @@ -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);