[libvirt PATCH] qemu_nbdkit: fix possible null dereference

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

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>
participants (2)
-
Pavel Hrdina
-
Peter Krempa