[libvirt] [PATCH] Fix crash accessing a NULL URI when looking up auth credentials
Daniel P. Berrange
berrange at redhat.com
Fri Sep 21 08:37:04 UTC 2012
Ping
On Wed, Sep 12, 2012 at 04:41:16PM +0100, Daniel P. Berrange wrote:
> From: "Daniel P. Berrange" <berrange at redhat.com>
>
> 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
> ---
> src/remote/remote_driver.c | 2 +-
> src/util/virauth.c | 2 +-
> 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 cf1f079..8c6c807 100644
> --- a/src/remote/remote_driver.c
> +++ b/src/remote/remote_driver.c
> @@ -3281,7 +3281,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 5539c3c..ff8d0d4 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 571bf3c..de927fa 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__ */
> --
> 1.7.11.4
>
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
More information about the libvir-list
mailing list