]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
Fix crash accessing a NULL URI when looking up auth credentials
authorDaniel P. Berrange <berrange@redhat.com>
Wed, 12 Sep 2012 15:40:08 +0000 (16:40 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Fri, 21 Sep 2012 09:13:53 +0000 (10:13 +0100)
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>
src/remote/remote_driver.c
src/util/virauth.c
src/util/viruri.h

index 3ee385c6e3c6085e4fcf2e2efb0b71ef45c91b7b..fc4c69615abbebaeb04e35561d21be77508cc05b 100644 (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;
index 0d92a1d70a3e9bbf04ddf5dc532c63157fee9da6..6d9935d6e55140964bd620762ec805ed2a9b8e23 100644 (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;
index aabd89454ca2b4c26d71b16ef304a53b3e412f3d..3cfc7d39d9e493684a03f5d68a2f32028f2b876d 100644 (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__ */