[PATCH 3/6] tests: qemumonitorutils: Don't crash on wrong monitor command

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

 



virQEMUQAPISchemaPathGet returns success when a given schema path was
not found but the returned object is set to NULL. This meant that we'd
call testQEMUSchemaValidate with the schemaroot being NULL which lead to
a crash if a mistyped monitor command was tested.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 tests/qemumonitortestutils.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tests/qemumonitortestutils.c b/tests/qemumonitortestutils.c
index d857c381a4..15eba5898e 100644
--- a/tests/qemumonitortestutils.c
+++ b/tests/qemumonitortestutils.c
@@ -564,7 +564,8 @@ qemuMonitorTestProcessCommandDefaultValidate(qemuMonitorTestPtr test,
     if (virAsprintf(&schemapath, "%s/arg-type", cmdname) < 0)
         goto cleanup;

-    if (virQEMUQAPISchemaPathGet(schemapath, test->qapischema, &schemaroot) < 0) {
+    if (virQEMUQAPISchemaPathGet(schemapath, test->qapischema, &schemaroot) < 0 ||
+        !schemaroot) {
         if (qemuMonitorReportError(test,
                                    "command '%s' not found in QAPI schema",
                                    cmdname) == 0)
-- 
2.16.2

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux