]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: monitor: Fix device matching in qemuMonitorJSONBlockIoThrottleInfo
authorPeter Krempa <pkrempa@redhat.com>
Wed, 22 Aug 2018 11:20:52 +0000 (13:20 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 22 Aug 2018 11:55:27 +0000 (13:55 +0200)
We should compare the alias/qdev id only when it was provided by the
caller and when it was found in the reply. Otherwise we could
dereference a NULL pointer. STRNEQ_NULLABLE is not appropriate since
it would return 'true' if the string was not present in the JSON output.

Found by Coverity.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
src/qemu/qemu_monitor_json.c

index 5cd38710e5c8dbad487d3f4a3fd91631e800f187..ddfa261743cb1a4f0d4e0281354f3709cf36b188 100644 (file)
@@ -5001,8 +5001,8 @@ qemuMonitorJSONBlockIoThrottleInfo(virJSONValuePtr io_throttle,
             goto cleanup;
         }
 
-        if ((drivealias && STRNEQ(current_drive, drivealias)) ||
-            (qdevid && STRNEQ(current_qdev, qdevid)))
+        if ((drivealias && current_drive && STRNEQ(current_drive, drivealias)) ||
+            (qdevid && current_qdev && STRNEQ(current_qdev, qdevid)))
             continue;
 
         found = true;