mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
tools: check return value of asprintf() in xenhypfs
asprintf() can fail, so check its return value. Additionally fix a memory leak in xenhypfs. Reported-by: Andrew Cooper <andrew.cooper3@citrix.com> Signed-off-by: Juergen Gross <jgross@suse.com> Acked-by: Wei Liu <wl@xen.org> Release-acked-by: Paul Durrant <paul@xen.org>
This commit is contained in:
1 parent
52a9022fe9
commit
370b41113e
1 file changed
+6
-1
@@ -148,9 +148,14 @@ static int xenhypfs_tree_sub(char *path, unsigned int depth)
|
||||
printf("%*s%s%s\n", depth * 2, "", ent[i].name,
|
||||
ent[i].type == xenhypfs_type_dir ? "/" : "");
|
||||
if (ent[i].type == xenhypfs_type_dir) {
|
||||
asprintf(&p, "%s%s%s", path, (depth == 1) ? "" : "/", ent[i].name);
|
||||
if (asprintf(&p, "%s%s%s", path, (depth == 1) ? "" : "/",
|
||||
ent[i].name) < 0) {
|
||||
ret = 2;
|
||||
break;
|
||||
}
|
||||
if (xenhypfs_tree_sub(p, depth + 1))
|
||||
ret = 2;
|
||||
free(p);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||