From: Daniel P. Berrange Date: Wed, 12 Sep 2012 15:40:08 +0000 (+0100) Subject: Fix crash accessing a NULL URI when looking up auth credentials X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=ab42772a46e17d14204359a17234b2d9cee0ddb6;p=people%2Fliuw%2Flibxenctrl-split%2Flibvirt.git 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 --- 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__ */