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

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

index 1b9e4b6704a2e021dc582fd23fc3fc3c97d09481..7e7098317d683111c0c0151fdccc9b840848e639 100644 (file)
@@ -175,6 +175,12 @@ virAuthGetUsernamePath(const char *path,
         if (auth->credtype[ncred] != VIR_CRED_AUTHNAME)
             continue;
 
+        if (!auth->cb) {
+            virReportError(VIR_ERR_INVALID_ARG, "%s",
+                           _("Missing authentication callback"));
+            return NULL;
+        }
+
         cred.type = VIR_CRED_AUTHNAME;
         cred.prompt = prompt;
         cred.challenge = hostname;
@@ -251,6 +257,12 @@ virAuthGetPasswordPath(const char *path,
             continue;
         }
 
+        if (!auth->cb) {
+            virReportError(VIR_ERR_INVALID_ARG, "%s",
+                           _("Missing authentication callback"));
+            return NULL;
+        }
+
         cred.type = auth->credtype[ncred];
         cred.prompt = prompt;
         cred.challenge = hostname;