[PATCH] remoteOpenConn: Pass correct variable to virConnectSetIdentity()

Michal Privoznik posted 1 patch 1 year, 11 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/87581c914745444ea2f6499063b5d088e3a4ce24.1652947218.git.mprivozn@redhat.com
src/remote/remote_daemon_dispatch.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] remoteOpenConn: Pass correct variable to virConnectSetIdentity()
Posted by Michal Privoznik 1 year, 11 months ago
The remoteOpenConn() function was refactored recently. As a part
of that new variable @newconn was introduced which holds
virConnect object as it's being gradually constructed throughout
the function. At the very end, when everything succeeded the
variable is stolen into passed @conn. However, there was one
line missed in the refactor which still access the @conn instead
of @newconn leading to a NULL dereference.

Fixes: f7c422993e4c7ca3e58b1d0d69f4772851af399f
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 src/remote/remote_daemon_dispatch.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon_dispatch.c
index c1f85925a3..0fde4233a5 100644
--- a/src/remote/remote_daemon_dispatch.c
+++ b/src/remote/remote_daemon_dispatch.c
@@ -1829,7 +1829,7 @@ remoteOpenConn(const char *uri,
     VIR_DEBUG("Opened driver %p", newconn);
 
     if (preserveIdentity) {
-        if (virConnectSetIdentity(*conn, identparams->par, identparams->npar, 0) < 0)
+        if (virConnectSetIdentity(newconn, identparams->par, identparams->npar, 0) < 0)
             return -1;
 
         VIR_DEBUG("Forwarded current identity to secondary driver");
-- 
2.35.1
Re: [PATCH] remoteOpenConn: Pass correct variable to virConnectSetIdentity()
Posted by Erik Skultety 1 year, 11 months ago
On Thu, May 19, 2022 at 10:00:26AM +0200, Michal Privoznik wrote:
> The remoteOpenConn() function was refactored recently. As a part
> of that new variable @newconn was introduced which holds
> virConnect object as it's being gradually constructed throughout
> the function. At the very end, when everything succeeded the
> variable is stolen into passed @conn. However, there was one
> line missed in the refactor which still access the @conn instead
> of @newconn leading to a NULL dereference.
> 
> Fixes: f7c422993e4c7ca3e58b1d0d69f4772851af399f
> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
> ---

CI++

Reviewed-by: Erik Skultety <eskultet@redhat.com>