1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

fix bug with "use other password"

It's more trouble than it's worth to shallow copy; changed to deep copy with STL
This commit is contained in:
Dubslow 2015-01-15 21:41:10 -06:00
parent 139cd3f4a6
commit 826d60c876
No known key found for this signature in database
GPG Key ID: 3DB8E05315C220AA

View File

@ -48,20 +48,19 @@ void Core::setPassword(QString& password, PasswordType passtype, uint8_t* salt)
password.clear();
}
#include <algorithm>
void Core::useOtherPassword(PasswordType type)
{
clearPassword(type);
if (type == ptHistory)
pwsaltedkeys[ptHistory] = pwsaltedkeys[ptMain];
else if (type == ptMain)
pwsaltedkeys[ptMain] = pwsaltedkeys[ptHistory];
pwsaltedkeys[type] = new uint8_t[tox_pass_key_length()];
PasswordType other = (type == ptMain) ? ptHistory : ptMain;
std::copy(pwsaltedkeys[other], pwsaltedkeys[other]+tox_pass_key_length(), pwsaltedkeys[type]);
}
void Core::clearPassword(PasswordType passtype)
{
PasswordType other = (passtype == ptMain) ? ptHistory : ptMain;
if (pwsaltedkeys[passtype] == pwsaltedkeys[other])
pwsaltedkeys[other] = nullptr;
delete[] pwsaltedkeys[passtype];
pwsaltedkeys[passtype] = nullptr;
}