diff --git a/modules/saslplain.cpp b/modules/saslplain.cpp index ba60bc97..264f7643 100644 --- a/modules/saslplain.cpp +++ b/modules/saslplain.cpp @@ -43,12 +43,12 @@ class CSASLMechanismPlain : public CModule { auto spAuth = std::make_shared(this, sAuthcId, sPassword); CZNC::Get().AuthUser(spAuth); - return HALTMODS; - } + return HALTMODS; + } void OnGetSASLMechanisms(SCString& ssMechanisms) override { ssMechanisms.insert("PLAIN"); - } + } }; template <> diff --git a/src/Client.cpp b/src/Client.cpp index 28b52c15..4206cd7f 100644 --- a/src/Client.cpp +++ b/src/Client.cpp @@ -829,7 +829,7 @@ void CClient::HandleCap(const CMessage& Message) { PutClient(":irc.znc.in 906 " + GetNick() + " :SASL authentication aborted"); m_sSASLMechanism = ""; - m_bSASLAuthenticating = false; + m_bSASLAuthenticating = false; } if (!m_pUser && m_bGotUser && @@ -1105,30 +1105,30 @@ void CClient::OnAuthenticateMessage(CAuthenticateMessage& Message) { }; if (!m_bSASL) return; - - if (!m_sSASLUser.empty() || IsAttached()) { + + if (!m_sSASLUser.empty() || IsAttached()) { PutClient(":irc.znc.in 907 " + GetNick() + " :You have already authenticated using SASL"); return; } - - if (!m_bSASLAuthenticating || sMessage.Equals("*")) { + + if (!m_bSASLAuthenticating || sMessage.Equals("*")) { PutClient(":irc.znc.in 906 " + GetNick() + " :SASL authentication aborted"); if (!IsAttached()) { - m_bSASLAuthenticating = false; + m_bSASLAuthenticating = false; SASLReset(); - } + } return; } - if (iBufferSize > uiMaxSASLMsgLength) { + if (iBufferSize > uiMaxSASLMsgLength) { PutClient(":irc.znc.in 905 " + GetNick() + " :SASL message too long"); SASLReset(); return; } - if (m_sSASLMechanism.empty()) { + if (m_sSASLMechanism.empty()) { SCString ssMechanisms; auto sMechanisms = EnumerateSASLMechanisms(ssMechanisms); @@ -1153,8 +1153,8 @@ void CClient::OnAuthenticateMessage(CAuthenticateMessage& Message) { } else { PutClient("AUTHENTICATE +"); } - return; - } + return; + } if (m_sSASLBuffer.length() + sMessage.length() > 10 * 1024) { PutClient(":irc.znc.in 904 " + GetNick() + " :SASL response too long"); @@ -1162,48 +1162,49 @@ void CClient::OnAuthenticateMessage(CAuthenticateMessage& Message) { return; } - if (iBufferSize == uiMaxSASLMsgLength) { - m_sSASLBuffer.append(sMessage); - return; - } + if (iBufferSize == uiMaxSASLMsgLength) { + m_sSASLBuffer.append(sMessage); + return; + } if (sMessage != "+") { m_sSASLBuffer += sMessage; } - m_sSASLBuffer.Base64Decode(); + m_sSASLBuffer.Base64Decode(); - CString sResponse; - bool bResult; + CString sResponse; + bool bResult; CString sSASLUser; - GLOBALMODULECALL(OnClientSASLAuthenticate( - m_sSASLMechanism, m_sSASLBuffer, sSASLUser, - sResponse, bAuthenticationSuccess), - &bResult); + GLOBALMODULECALL( + OnClientSASLAuthenticate(m_sSASLMechanism, m_sSASLBuffer, sSASLUser, + sResponse, bAuthenticationSuccess), + &bResult); m_sSASLBuffer.clear(); - if (bResult && !sResponse.empty()) { - SASLChallenge(sResponse); + if (bResult && !sResponse.empty()) { + SASLChallenge(sResponse); return; - } + } - auto pUser = CZNC::Get().FindUser(sSASLUser); + auto pUser = CZNC::Get().FindUser(sSASLUser); - if (pUser && bAuthenticationSuccess) { - PutClient(":irc.znc.in 900 " + GetNick() + " " + GetNick() + "!" + - pUser->GetIdent() + "@" + GetHostName() + " " + sSASLUser + - " :You are now logged in as " + sSASLUser); - PutClient(":irc.znc.in 903 " + GetNick() + - " :SASL authentication successful"); - m_sSASLUser = sSASLUser; - m_bSASLAuthenticating = false; - } else { - PutClient(":irc.znc.in 904 " + GetNick() + " :SASL authentication failed"); - SASLReset(); - } + if (pUser && bAuthenticationSuccess) { + PutClient(":irc.znc.in 900 " + GetNick() + " " + GetNick() + "!" + + pUser->GetIdent() + "@" + GetHostName() + " " + sSASLUser + + " :You are now logged in as " + sSASLUser); + PutClient(":irc.znc.in 903 " + GetNick() + + " :SASL authentication successful"); + m_sSASLUser = sSASLUser; + m_bSASLAuthenticating = false; + } else { + PutClient(":irc.znc.in 904 " + GetNick() + + " :SASL authentication failed"); + SASLReset(); + } - return; + return; } CString CClient::EnumerateSASLMechanisms(SCString& ssMechanisms) { diff --git a/src/Message.cpp b/src/Message.cpp index 1538caab..9455002c 100644 --- a/src/Message.cpp +++ b/src/Message.cpp @@ -234,7 +234,7 @@ void CMessage::Parse(const CString& sMessage) { if (m_bColon) { ++begin; m_vsParams.push_back(std::string(begin, end - begin)); - begin = end; + begin = end; } else { m_vsParams.push_back(std::string(next_word())); }