]> xenbits.xensource.com Git - libvirt.git/commitdiff
util: Alter virAuthGet*Path API to check valid parameters
authorJohn Ferlan <jferlan@redhat.com>
Tue, 14 Aug 2018 14:03:10 +0000 (10:03 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Wed, 15 Aug 2018 19:41:34 +0000 (15:41 -0400)
Before trying to dereference @auth, let's ensure it's valid.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Marcos Paulo de Souza <marcos.souza.org@gmail.com>
src/util/virauth.c

index 759b8f0cd3677f4c810fe04404b234ec85d07fa0..1b9e4b6704a2e021dc582fd23fc3fc3c97d09481 100644 (file)
@@ -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,