提交 ab42772a 编写于 作者: D Daniel P. Berrange

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: NDaniel P. Berrange <berrange@redhat.com>
上级 1437ea6f
...@@ -3726,7 +3726,7 @@ static int remoteAuthFillFromConfig(virConnectPtr conn, ...@@ -3726,7 +3726,7 @@ static int remoteAuthFillFromConfig(virConnectPtr conn,
if (virAuthConfigLookup(state->config, if (virAuthConfigLookup(state->config,
"libvirt", "libvirt",
conn->uri->server, VIR_URI_SERVER(conn->uri),
credname, credname,
&value) < 0) &value) < 0)
goto cleanup; goto cleanup;
......
...@@ -130,7 +130,7 @@ virAuthGetCredential(virConnectPtr conn, ...@@ -130,7 +130,7 @@ virAuthGetCredential(virConnectPtr conn,
if (virAuthConfigLookup(config, if (virAuthConfigLookup(config,
servicename, servicename,
conn->uri->server, VIR_URI_SERVER(conn->uri),
credname, credname,
&tmp) < 0) &tmp) < 0)
goto cleanup; goto cleanup;
......
...@@ -60,4 +60,6 @@ char *virURIFormatParams(virURIPtr uri); ...@@ -60,4 +60,6 @@ char *virURIFormatParams(virURIPtr uri);
void virURIFree(virURIPtr uri); void virURIFree(virURIPtr uri);
# define VIR_URI_SERVER(uri) ((uri) && (uri)->server ? (uri)->server : "localhost")
#endif /* __VIR_URI_H__ */ #endif /* __VIR_URI_H__ */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册