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

Jonathon Jongsma posted 1 patch 4 years, 7 months ago
Test syntax-check passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20190830160909.6419-1-jjongsma@redhat.com
src/qemu/qemu_agent.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
[libvirt] [PATCH] qemu: Validate arg in qemuAgentErrorComandUnsupported()
Posted by Jonathon Jongsma 4 years, 7 months ago
Coverity noted that 'reply' can be NULL after calling
qemuAgentCommand().  Avoid dereferencing reply in
qemuAgentErrorComandUnsupported() in that case.

Signed-off-by: Jonathon Jongsma <jjongsma@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

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] qemu: Validate arg in qemuAgentErrorComandUnsupported()
Posted by John Ferlan 4 years, 7 months ago

On 8/30/19 12:09 PM, Jonathon Jongsma wrote:
> Coverity noted that 'reply' can be NULL after calling
> qemuAgentCommand().  Avoid dereferencing reply in
> qemuAgentErrorComandUnsupported() in that case.
> 
> Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
> ---
>  src/qemu/qemu_agent.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 

Reviewed-by: John Ferlan <jferlan@redhat.com>

John

(I've pushed as a bugfix during freeze)

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