libxl: fix double free of ifname, when makes args for qemu.

In libxl_build_device_model_args_new, vifs[i].ifname can be free two
times, by the gc, and by freeing the vifs structures. This patch avoids
this.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
committer: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
 tools/libxl/libxl.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)
This commit is contained in:
Anthony PERARD committed 2010-12-13 17:58:20 +00:00
1 parent f662bb114a
commit 3c97df22be
1 file changed
+7 -3
+7 -3
View File
@@ -1341,14 +1341,18 @@ static char ** libxl_build_device_model_args_new(libxl__gc *gc,
char *smac = libxl__sprintf(gc, "%02x:%02x:%02x:%02x:%02x:%02x",
vifs[i].mac[0], vifs[i].mac[1], vifs[i].mac[2],
vifs[i].mac[3], vifs[i].mac[4], vifs[i].mac[5]);
if (!vifs[i].ifname)
vifs[i].ifname = libxl__sprintf(gc, "tap%d.%d", info->domid, vifs[i].devid);
char *ifname;
if (!vifs[i].ifname) {
ifname = libxl__sprintf(gc, "tap%d.%d", info->domid, vifs[i].devid);
} else {
ifname = vifs[i].ifname;
}
flexarray_set(dm_args, num++, "-net");
flexarray_set(dm_args, num++, libxl__sprintf(gc, "nic,vlan=%d,macaddr=%s,model=%s",
vifs[i].devid, smac, vifs[i].model));
flexarray_set(dm_args, num++, "-net");
flexarray_set(dm_args, num++, libxl__sprintf(gc, "tap,vlan=%d,ifname=%s,script=no",
vifs[i].devid, vifs[i].ifname));
vifs[i].devid, ifname));
ioemu_vifs++;
}
}
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.