提交 d585847d 编写于 作者: J John Ferlan 提交者: Peter Krempa

util: Fix memory leak in virAuthGetCredential

Since 5084091a, @tmp is filled by a g_key_file_get_string which is
now an allocated string as opposed to some hash table lookup value,
so we need to treat it as so.

Found by Coverity
Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
Reviewed-by: NPeter Krempa <pkrempa@redhat.com>
上级 3a58613b
......@@ -4097,7 +4097,7 @@ static int remoteAuthFillFromConfig(virConnectPtr conn,
}
for (ninteract = 0; state->interact[ninteract].id != 0; ninteract++) {
const char *value = NULL;
char *value = NULL;
switch (state->interact[ninteract].id) {
case SASL_CB_USER:
......
......@@ -107,7 +107,6 @@ virAuthGetCredential(const char *servicename,
char **value)
{
g_autoptr(virAuthConfig) config = NULL;
const char *tmp;
*value = NULL;
......@@ -121,11 +120,9 @@ virAuthGetCredential(const char *servicename,
servicename,
hostname,
credname,
&tmp) < 0)
value) < 0)
return -1;
*value = g_strdup(tmp);
return 0;
}
......
......@@ -99,7 +99,7 @@ int virAuthConfigLookup(virAuthConfigPtr auth,
const char *service,
const char *hostname,
const char *credname,
const char **value)
char **value)
{
g_autofree char *authgroup = NULL;
g_autofree char *credgroup = NULL;
......
......@@ -37,6 +37,6 @@ int virAuthConfigLookup(virAuthConfigPtr auth,
const char *service,
const char *hostname,
const char *credname,
const char **value);
char **value);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(virAuthConfig, virAuthConfigFree);
......@@ -42,7 +42,7 @@ struct ConfigLookupData {
static int testAuthLookup(const void *args)
{
const struct ConfigLookupData *data = args;
const char *actual = NULL;
g_autofree char *actual = NULL;
int rv;
rv = virAuthConfigLookup(data->config,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册