mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 03:25:20 +00:00
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: John Ferlan <jferlan@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
3a58613b0c
commit
d585847d2e
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user