[libvirt] [PATCH] qemu: Validate arg in qemuAgentErrorComandUnsupported()

Jonathon Jongsma jjongsma at redhat.com
Fri Aug 30 16:09:09 UTC 2019


Coverity noted that 'reply' can be NULL after calling
qemuAgentCommand().  Avoid dereferencing reply in
qemuAgentErrorComandUnsupported() in that case.

Signed-off-by: Jonathon Jongsma <jjongsma at redhat.com>
---
 src/qemu/qemu_agent.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
index fddedf5cb6..34e1a85d64 100644
--- a/src/qemu/qemu_agent.c
+++ b/src/qemu/qemu_agent.c
@@ -1005,7 +1005,12 @@ static bool
 qemuAgentErrorCommandUnsupported(virJSONValuePtr reply)
 {
     const char *klass;
-    virJSONValuePtr error = virJSONValueObjectGet(reply, "error");
+    virJSONValuePtr error;
+
+    if (!reply)
+        return false;
+
+    error = virJSONValueObjectGet(reply, "error");
 
     if (!error)
         return false;
-- 
2.21.0




More information about the libvir-list mailing list