diff options
author | Daniel P. Berrange <berrange@redhat.com> | 2012-09-12 16:40:08 +0100 |
---|---|---|
committer | Daniel P. Berrange <berrange@redhat.com> | 2012-09-21 10:13:53 +0100 |
commit | ab42772a46e17d14204359a17234b2d9cee0ddb6 (patch) | |
tree | 66b4b7f95ea06cd9c683b45f04e2045a8a2158da /src | |
parent | Remove a redundant line in src/qemu/qemu_driver.c (diff) | |
download | libvirt-ab42772a46e17d14204359a17234b2d9cee0ddb6.tar.gz libvirt-ab42772a46e17d14204359a17234b2d9cee0ddb6.tar.bz2 libvirt-ab42772a46e17d14204359a17234b2d9cee0ddb6.zip |
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>
Diffstat (limited to 'src')
-rw-r--r-- | src/remote/remote_driver.c | 2 | ||||
-rw-r--r-- | src/util/virauth.c | 2 | ||||
-rw-r--r-- | src/util/viruri.h | 2 |
3 files changed, 4 insertions, 2 deletions
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 3ee385c6e..fc4c69615 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -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; diff --git a/src/util/virauth.c b/src/util/virauth.c index 0d92a1d70..6d9935d6e 100644 --- a/src/util/virauth.c +++ b/src/util/virauth.c @@ -130,7 +130,7 @@ virAuthGetCredential(virConnectPtr conn, if (virAuthConfigLookup(config, servicename, - conn->uri->server, + VIR_URI_SERVER(conn->uri), credname, &tmp) < 0) goto cleanup; diff --git a/src/util/viruri.h b/src/util/viruri.h index aabd89454..3cfc7d39d 100644 --- a/src/util/viruri.h +++ b/src/util/viruri.h @@ -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__ */ |