[libvirt PATCH] qemu_nbdkit: fix possible null dereference

Pavel Hrdina posted 1 patch 7 months, 1 week ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/fe98e3c3fc65b04e527eb17c2551e76cd43d2024.1695210846.git.phrdina@redhat.com
src/qemu/qemu_nbdkit.c | 3 +++
1 file changed, 3 insertions(+)
[libvirt PATCH] qemu_nbdkit: fix possible null dereference
Posted by Pavel Hrdina 7 months, 1 week ago
Function virGetConnectSecret() can return NULL so we need to check it
since in virSecretGetSecretString() it gets dereferenced.

Reported-by: coverity
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
---
 src/qemu/qemu_nbdkit.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/qemu/qemu_nbdkit.c b/src/qemu/qemu_nbdkit.c
index 66b09cd240..17819ca992 100644
--- a/src/qemu/qemu_nbdkit.c
+++ b/src/qemu/qemu_nbdkit.c
@@ -971,6 +971,9 @@ qemuNbdkitProcessBuildCommandAuth(virStorageAuthDef *authdef,
     }
 
     conn = virGetConnectSecret();
+    if (!conn)
+        return -1;
+
     if (virSecretGetSecretString(conn,
                                  &authdef->seclookupdef,
                                  secrettype,
-- 
2.41.0
Re: [libvirt PATCH] qemu_nbdkit: fix possible null dereference
Posted by Peter Krempa 7 months, 1 week ago
On Wed, Sep 20, 2023 at 14:01:29 +0200, Pavel Hrdina wrote:
> Function virGetConnectSecret() can return NULL so we need to check it
> since in virSecretGetSecretString() it gets dereferenced.
> 
> Reported-by: coverity
> Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
> ---
>  src/qemu/qemu_nbdkit.c | 3 +++
>  1 file changed, 3 insertions(+)

Reviewed-by: Peter Krempa <pkrempa@redhat.com>