[libvirt] [PATCH 7/7] qemu: Check for missing 'return' in qemuMonitorJSONCheckReply

John Ferlan jferlan at redhat.com
Tue Apr 17 16:22:18 UTC 2018


If the "return" is not in the reply, then the subsequent
virJSONValueGetType will not be happy.

Found by Coverity

Signed-off-by: John Ferlan <jferlan at redhat.com>
---
 src/qemu/qemu_monitor_json.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 410fa178b2..681c0575c3 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -423,7 +423,12 @@ qemuMonitorJSONCheckReply(virJSONValuePtr cmd,
     if (qemuMonitorJSONCheckError(cmd, reply) < 0)
         return -1;
 
-    data = virJSONValueObjectGet(reply, "return");
+    if (!(data = virJSONValueObjectGet(reply, "return"))) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("missing 'return' for returned data"));
+        return -1;
+    }
+
     if (virJSONValueGetType(data) != type) {
         char *cmdstr = virJSONValueToString(cmd, false);
         char *retstr = virJSONValueToString(data, false);
-- 
2.13.6




More information about the libvir-list mailing list