From: John Ferlan Date: Tue, 14 Aug 2018 14:05:33 +0000 (-0400) Subject: util: Alter virAuthGet*Path API to check valid callback X-Git-Tag: v4.7.0-rc1~141 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3dc6b00f0d347a9fb2964b3350cc4dd4ca809b59;p=thirdparty%2Flibvirt.git util: Alter virAuthGet*Path API to check valid callback Before trying to call @auth->cb, let's ensure it exists. Signed-off-by: John Ferlan Reviewed-by: Marcos Paulo de Souza --- diff --git a/src/util/virauth.c b/src/util/virauth.c index 1b9e4b6704..7e7098317d 100644 --- a/src/util/virauth.c +++ b/src/util/virauth.c @@ -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;