]> xenbits.xensource.com Git - libvirt.git/commitdiff
virauth.c: Check for valid auth callback
authorMarcos Paulo de Souza <marcos.souza.org@gmail.com>
Fri, 3 Aug 2018 00:27:51 +0000 (21:27 -0300)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 14 Aug 2018 14:03:04 +0000 (16:03 +0200)
Instead of adding the same check for every drivers, execute the checks
in virAuthGetUsername and virAuthGetPassword. These funtions are called
when user is not set in the URI.

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

index 8c450b6b314147a404d601c5af679c98aeff3b55..759b8f0cd3677f4c810fe04404b234ec85d07fa0 100644 (file)
@@ -198,6 +198,12 @@ virAuthGetUsername(virConnectPtr conn,
     if (virAuthGetConfigFilePath(conn, &path) < 0)
         return NULL;
 
+    if (!auth || !auth->cb) {
+        virReportError(VIR_ERR_INVALID_ARG, "%s",
+                       _("Missing or invalid auth pointer"));
+        return NULL;
+    }
+
     return virAuthGetUsernamePath(path, auth, servicename,
                                  defaultUsername, hostname);
 }
@@ -262,5 +268,11 @@ virAuthGetPassword(virConnectPtr conn,
     if (virAuthGetConfigFilePath(conn, &path) < 0)
         return NULL;
 
+    if (!auth || !auth->cb) {
+        virReportError(VIR_ERR_INVALID_ARG, "%s",
+                       _("Missing or invalid auth pointer"));
+        return NULL;
+    }
+
     return virAuthGetPasswordPath(path, auth, servicename, username, hostname);
 }