From: John Ferlan Date: Tue, 14 Aug 2018 14:03:10 +0000 (-0400) Subject: util: Alter virAuthGet*Path API to check valid parameters X-Git-Tag: v4.7.0-rc1~142 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f707935abfae1b5c7ce3d317999e66c8bbe13bb2;p=thirdparty%2Flibvirt.git 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 Reviewed-by: Marcos Paulo de Souza --- 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,