From: Christian Brauner Date: Thu, 14 Jun 2018 20:10:26 +0000 (+0200) Subject: coverity: #1425767 X-Git-Tag: lxc-3.1.0~247^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=76c00d391a2b9ed8ee02bc3c8db2f67adcbcff82;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 be07aeb6f..f22c41747 100644 --- a/src/lxc/storage/btrfs.c +++ b/src/lxc/storage/btrfs.c @@ -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);