[libvirt] [PATCH] lib: Don't access configuration if none is present

Commit e457d5ef2015e6106094b85f8bbd1582002edc4d adds ability to pass the default URI using the client configuration file. If the file is not present, it still accesses the NULL config object causing a segfault. Caught running "make check". --- src/libvirt.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/src/libvirt.c b/src/libvirt.c index 1c0cdf7..d0b1b28 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -1085,7 +1085,8 @@ virConnectOpenResolveURIAlias(virConfPtr conf, *uri = NULL; - if ((value = virConfGetValue(conf, "uri_aliases"))) + if (conf && + (value = virConfGetValue(conf, "uri_aliases"))) ret = virConnectOpenFindURIAliasMatch(value, alias, uri); else ret = 0; -- 1.7.3.4

On Thu, Mar 15, 2012 at 05:22:28PM +0100, Peter Krempa wrote:
Commit e457d5ef2015e6106094b85f8bbd1582002edc4d adds ability to pass the default URI using the client configuration file. If the file is not present, it still accesses the NULL config object causing a segfault.
Caught running "make check". --- src/libvirt.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/src/libvirt.c b/src/libvirt.c index 1c0cdf7..d0b1b28 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -1085,7 +1085,8 @@ virConnectOpenResolveURIAlias(virConfPtr conf,
*uri = NULL;
- if ((value = virConfGetValue(conf, "uri_aliases"))) + if (conf && + (value = virConfGetValue(conf, "uri_aliases"))) ret = virConnectOpenFindURIAliasMatch(value, alias, uri); else ret = 0;
ACK Daniel -- |: 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 :|

On 03/15/2012 05:37 PM, Daniel P. Berrange wrote:
On Thu, Mar 15, 2012 at 05:22:28PM +0100, Peter Krempa wrote:
Commit e457d5ef2015e6106094b85f8bbd1582002edc4d adds ability to pass the default URI using the client configuration file. If the file is not present, it still accesses the NULL config object causing a segfault.
Caught running "make check". ---
Thanks, pushed. Peter
participants (2)
-
Daniel P. Berrange
-
Peter Krempa