[libvirt] [PATCH 01/11] util: Alter virAuthGet*Path API to check valid parameters

John Ferlan jferlan at redhat.com
Tue Aug 14 17:07:46 UTC 2018


Before trying to dereference @auth, let's ensure it's valid.

Signed-off-by: John Ferlan <jferlan at redhat.com>
---
 src/util/virauth.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/util/virauth.c b/src/util/virauth.c
index 759b8f0cd3..1b9e4b6704 100644
--- a/src/util/virauth.c
+++ b/src/util/virauth.c
@@ -153,6 +153,12 @@ virAuthGetUsernamePath(const char *path,
     if (ret != NULL)
         return ret;
 
+    if (!auth) {
+        virReportError(VIR_ERR_INVALID_ARG, "%s",
+                       _("Missing authentication credentials"));
+        return NULL;
+    }
+
     memset(&cred, 0, sizeof(virConnectCredential));
 
     if (defaultUsername != NULL) {
@@ -226,6 +232,12 @@ virAuthGetPasswordPath(const char *path,
     if (ret != NULL)
         return ret;
 
+    if (!auth) {
+        virReportError(VIR_ERR_INVALID_ARG, "%s",
+                       _("Missing authentication credentials"));
+        return NULL;
+    }
+
     memset(&cred, 0, sizeof(virConnectCredential));
 
     if (virAsprintf(&prompt, _("Enter %s's password for %s"), username,
-- 
2.17.1




More information about the libvir-list mailing list