libxl: Fix SEGV in network-attach

When "device/vif" directory exists but is empty l!=NULL, but nb==0, so
l[nb-1] is invalid.  Add missing check.

Signed-off-by: Marek Marczykowski <marmarek@invisiblethingslab.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
(cherry picked from commit 9f1a6ff38b)

Conflicts:
	tools/libxl/libxl.c
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
This commit is contained in:
Ian Jackson authored and Ian Jackson committed 2013-04-18 17:44:17 +01:00
1 parent a12ed39665
commit 21c31a811c
1 file changed
+2 -1
+2 -1
View File
@@ -1207,7 +1207,8 @@ int libxl_device_nic_add(libxl_ctx *ctx, uint32_t domid, libxl_device_nic *nic)
goto out_free;
}
if (!(l = libxl__xs_directory(&gc, XBT_NULL,
libxl__sprintf(&gc, "%s/device/vif", dompath), &nb))) {
libxl__sprintf(gc, "%s/device/vif", dompath), &nb)) ||
nb == 0) {
nic->devid = 0;
} else {
nic->devid = strtoul(l[nb - 1], NULL, 10) + 1;
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.