提交 f707935a 编写于 作者: J John Ferlan

util: Alter virAuthGet*Path API to check valid parameters

Before trying to dereference @auth, let's ensure it's valid.
Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
Reviewed-by: NMarcos Paulo de Souza <marcos.souza.org@gmail.com>
上级 bfd91dc0
......@@ -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,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册