]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Fix crash in qemuBuildDeviceCommandlineHandleOverrides
authorPeter Krempa <pkrempa@redhat.com>
Mon, 6 Jun 2022 08:10:44 +0000 (10:10 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 6 Jun 2022 08:41:38 +0000 (10:41 +0200)
'STREQ' is used to compare the override alias with the device alias.
While the parser ensures that the override alias is non-NULL, the device
alias may be NULL and STREQ doesn't handle that.

Fixes: 38ab5c9ead5
Resolves: https://gitlab.com/libvirt/libvirt/-/issues/321
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_command.c

index 52e4ef03cdefcb82c28116b62a035bbd90d28b2a..4f4d8cf25cdedbb5f9ae3c37f6a89c101a0c79e3 100644 (file)
@@ -240,6 +240,10 @@ qemuBuildDeviceCommandlineHandleOverrides(virJSONValue *props,
     const char *alias = virJSONValueObjectGetString(props, "id");
     size_t i;
 
+    /* If the device doesn't have an alias we can't override its props */
+    if (!alias)
+        return;
+
     for (i = 0; i < nsdef->ndeviceOverride; i++) {
         qemuDomainXmlNsDeviceOverride *dev = nsdef->deviceOverride + i;
         size_t j;