mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 03:25:20 +00:00
virNetSSHSessionAuthAddPasswordAuth: Don't access unlocked 'sess'
'sess->authPath' is modified before locking the 'sess' object.
Additionally on failure of 'virAuthGetConfigFilePathURI' 'sess' would be
unlocked even when it was not yet locked.
Fixes: 273745b431
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
c97b632283
commit
6aed6becec
@ -970,15 +970,17 @@ virNetSSHSessionAuthAddPasswordAuth(virNetSSHSession *sess,
|
|||||||
{
|
{
|
||||||
virNetSSHAuthMethod *auth;
|
virNetSSHAuthMethod *auth;
|
||||||
|
|
||||||
|
virObjectLock(sess);
|
||||||
|
|
||||||
if (uri) {
|
if (uri) {
|
||||||
VIR_FREE(sess->authPath);
|
VIR_FREE(sess->authPath);
|
||||||
|
|
||||||
if (virAuthGetConfigFilePathURI(uri, &sess->authPath) < 0)
|
if (virAuthGetConfigFilePathURI(uri, &sess->authPath) < 0) {
|
||||||
goto error;
|
virObjectUnlock(sess);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virObjectLock(sess);
|
|
||||||
|
|
||||||
if (!(auth = virNetSSHSessionAuthMethodNew(sess)))
|
if (!(auth = virNetSSHSessionAuthMethodNew(sess)))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user