Fix crash accessing a NULL URI when looking up auth credentials

When auto-probing hypervisor drivers, the conn->uri field will
initially be NULL. Care must be taken not to access members
when doing auth lookups in the config file

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrange 2012-09-12 16:40:08 +01:00
parent 1437ea6f48
commit ab42772a46
3 changed files with 4 additions and 2 deletions

View File

@ -3726,7 +3726,7 @@ static int remoteAuthFillFromConfig(virConnectPtr conn,
if (virAuthConfigLookup(state->config,
"libvirt",
conn->uri->server,
VIR_URI_SERVER(conn->uri),
credname,
&value) < 0)
goto cleanup;

View File

@ -130,7 +130,7 @@ virAuthGetCredential(virConnectPtr conn,
if (virAuthConfigLookup(config,
servicename,
conn->uri->server,
VIR_URI_SERVER(conn->uri),
credname,
&tmp) < 0)
goto cleanup;

View File

@ -60,4 +60,6 @@ char *virURIFormatParams(virURIPtr uri);
void virURIFree(virURIPtr uri);
# define VIR_URI_SERVER(uri) ((uri) && (uri)->server ? (uri)->server : "localhost")
#endif /* __VIR_URI_H__ */