[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH] vbox: Fix segfault on empty device source



<source file=''/> results in def->disks[i]->src == NULL. But
vboxDomainDefineXML didn't check def->disks[i]->src for NULL
and expected it to be a valid string.

Add checks for def->disks[i]->src != NULL to fix the segfault.
---
 src/vbox/vbox_tmpl.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index 1765d63..fefed1f 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -3519,7 +3519,8 @@ static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml) {
                 DEBUG("disk(%d) shared:     %s", i, def->disks[i]->shared ? "True" : "False");
 
                 if (def->disks[i]->device == VIR_DOMAIN_DISK_DEVICE_CDROM) {
-                    if (def->disks[i]->type == VIR_DOMAIN_DISK_TYPE_FILE) {
+                    if (def->disks[i]->type == VIR_DOMAIN_DISK_TYPE_FILE &&
+                        def->disks[i]->src != NULL) {
                         IDVDDrive *dvdDrive = NULL;
                         /* Currently CDROM/DVD Drive is always IDE
                          * Secondary Master so neglecting the following
@@ -3801,7 +3802,8 @@ static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml) {
             DEBUG("disk(%d) readonly:   %s", i, def->disks[i]->readonly ? "True" : "False");
             DEBUG("disk(%d) shared:     %s", i, def->disks[i]->shared ? "True" : "False");
 
-            if (def->disks[i]->type == VIR_DOMAIN_DISK_TYPE_FILE) {
+            if (def->disks[i]->type == VIR_DOMAIN_DISK_TYPE_FILE &&
+                def->disks[i]->src != NULL) {
                 IMedium   *medium          = NULL;
                 PRUnichar *mediumUUID      = NULL;
                 PRUnichar *mediumFileUtf16 = NULL;
-- 
1.6.3.3


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]