From 5a128712bc76d7db80ce362db7d7ddd5062088f8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Daniel=20P=2E=20Berrang=C3=A9?= Date: Fri, 31 Aug 2018 11:13:39 +0100 Subject: [PATCH] rpc: fix handling of SSH auth failure code MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The result of libssh2_userauth_password is being assigned to 'ret' in one branch and 'rc' in the other branch. Checks are all done against the 'ret' variable, so one branch never does the correct check. Reviewed-by: Andrea Bolognani Signed-off-by: Daniel P. Berrangé --- src/rpc/virnetsshsession.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/rpc/virnetsshsession.c b/src/rpc/virnetsshsession.c index 35dc6c5356..5e3ef992a9 100644 --- a/src/rpc/virnetsshsession.c +++ b/src/rpc/virnetsshsession.c @@ -706,9 +706,9 @@ virNetSSHAuthenticatePassword(virNetSSHSessionPtr sess, if (priv->password) { /* tunelled password authentication */ - if ((ret = libssh2_userauth_password(sess->session, - priv->username, - priv->password)) == 0) { + if ((rc = libssh2_userauth_password(sess->session, + priv->username, + priv->password)) == 0) { ret = 0; goto cleanup; } @@ -737,7 +737,7 @@ virNetSSHAuthenticatePassword(virNetSSHSessionPtr sess, goto cleanup; } - if (ret != LIBSSH2_ERROR_AUTHENTICATION_FAILED) + if (rc != LIBSSH2_ERROR_AUTHENTICATION_FAILED) break; VIR_FREE(password); @@ -750,10 +750,10 @@ virNetSSHAuthenticatePassword(virNetSSHSessionPtr sess, _("authentication failed: %s"), errmsg); /* determine exist status */ - if (ret == LIBSSH2_ERROR_AUTHENTICATION_FAILED) - return 1; + if (rc == LIBSSH2_ERROR_AUTHENTICATION_FAILED) + ret = 1; else - return -1; + ret = -1; cleanup: VIR_FREE(password); -- 2.47.2