mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 09:17:52 +03:00
virNetLibsshSessionAuthAddPasswordAuth: 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: 6917467c2b
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
c68a07eeb3
commit
76e005d1a5
@ -846,16 +846,17 @@ virNetLibsshSessionAuthAddPasswordAuth(virNetLibsshSession *sess,
|
|||||||
int ret;
|
int ret;
|
||||||
virNetLibsshAuthMethod *auth;
|
virNetLibsshAuthMethod *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) {
|
||||||
ret = -1;
|
virObjectUnlock(sess);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virObjectLock(sess);
|
|
||||||
|
|
||||||
if (!(auth = virNetLibsshSessionAuthMethodNew(sess))) {
|
if (!(auth = virNetLibsshSessionAuthMethodNew(sess))) {
|
||||||
ret = -1;
|
ret = -1;
|
||||||
|
Loading…
Reference in New Issue
Block a user