Make GetPass() return a CString instead of a char*

In theory this could lead to extra copies of the password in memory, but since
no caller actually makes sure that those passwords are forgotten as fast as
possible, I don't see why this should be done the Old Way(tm).


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1343 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
psychon
2009-01-23 18:46:39 +00:00
parent a92694c471
commit 7ab0b8d959
4 changed files with 8 additions and 12 deletions
+1 -1
View File
@@ -210,7 +210,7 @@ CString CUtils::SaltedHash(const CString& sPass, const CString& sSalt) {
return CString(sPass + sSalt).MD5();
}
char* CUtils::GetPass(const CString& sPrompt) {
CString CUtils::GetPass(const CString& sPrompt) {
PrintPrompt(sPrompt);
return getpass("");
}
+1 -1
View File
@@ -56,7 +56,7 @@ public:
static CString GetSaltedHashPass(CString& sSalt);
static CString GetSalt();
static CString SaltedHash(const CString& sPass, const CString& sSalt);
static char* GetPass(const CString& sPrompt);
static CString GetPass(const CString& sPrompt);
static bool GetInput(const CString& sPrompt, CString& sRet, const CString& sDefault = "", const CString& sHint = "");
static bool GetBoolInput(const CString& sPrompt, bool bDefault);
static bool GetBoolInput(const CString& sPrompt, bool *pbDefault = NULL);
+3 -5
View File
@@ -71,12 +71,10 @@ public:
{
if (m_sPassword.empty())
{
char *pTmp = CUtils::GetPass("Enter Encryption Key for away.so: ");
CString sTmp = CUtils::GetPass("Enter Encryption Key for away.so: ");
if (pTmp)
m_sPassword = CBlowfish::MD5(pTmp);
*pTmp = 0;
if (!sTmp.empty())
m_sPassword = CBlowfish::MD5(sTmp);
}
if (!BootStrap())
+3 -5
View File
@@ -71,12 +71,10 @@ public:
{
if (m_sPassword.empty())
{
char *pTmp = CUtils::GetPass("Enter Encryption Key for " + GetModName() + ".so");
CString sTmp = CUtils::GetPass("Enter Encryption Key for " + GetModName() + ".so");
if (pTmp)
m_sPassword = CBlowfish::MD5(pTmp);
*pTmp = 0;
if (!sTmp.empty())
m_sPassword = CBlowfish::MD5(sTmp);
}
const vector<CChan *>& vChans = m_pUser->GetChans();