From 69f4e093d0773ba2e7bbf57c001bbd72914d9473 Mon Sep 17 00:00:00 2001 From: Marcos Paulo de Souza Date: Thu, 2 Aug 2018 21:27:51 -0300 Subject: [PATCH] virauth.c: Check for valid auth callback 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 --- src/util/virauth.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/util/virauth.c b/src/util/virauth.c index 8c450b6b31..759b8f0cd3 100644 --- a/src/util/virauth.c +++ b/src/util/virauth.c @@ -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); }