]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: avoid leaking uninit data from hotplug to dumpxml
authorEric Blake <eblake@redhat.com>
Fri, 21 Oct 2011 23:09:17 +0000 (17:09 -0600)
committerEric Blake <eblake@redhat.com>
Mon, 24 Oct 2011 20:58:43 +0000 (14:58 -0600)
Detected by Coverity.  Both text and JSON monitors set only the
bus and unit fields, which means driveAddr.controller spends
life as garbage on the stack, and is then memcpy()'d into the
in-memory representation which the user can see via dumpxml.

* src/qemu/qemu_hotplug.c (qemuDomainAttachSCSIDisk): Only copy
defined fields.

src/qemu/qemu_hotplug.c

index bfa524b9b486dbf1038ca9c991d6f4fdd73811d4..037f4aa03c47fa2cb5e05ec797710a8535ee4b79 100644 (file)
@@ -505,7 +505,8 @@ int qemuDomainAttachSCSIDisk(struct qemud_driver *driver,
             /* XXX we should probably validate that the addr matches
              * our existing defined addr instead of overwriting */
             disk->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE;
-            memcpy(&disk->info.addr.drive, &driveAddr, sizeof(driveAddr));
+            disk->info.addr.drive.bus = driveAddr.bus;
+            disk->info.addr.drive.unit = driveAddr.unit;
         }
     }
     qemuDomainObjExitMonitorWithDriver(driver, vm);