[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

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



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

Signed-off-by: John Ferlan <jferlan 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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]