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

fix(profile): toxsave wasn't correctly encrypted

fix #4344
This commit is contained in:
sudden6 2017-04-23 13:50:20 +02:00
parent 52617ad075
commit 5b31cf6d9d
No known key found for this signature in database
GPG Key ID: 279509B499E032B9

View File

@ -141,7 +141,7 @@ Profile* Profile::loadProfile(QString name, const QString& password)
saveFile.close(); saveFile.close();
p = new Profile(name, password, false, data); p = new Profile(name, password, false, data);
p->passkey = std::move(tmpKey); p->passkey = std::move(tmpKey);
if (tmpKey) { if (p->passkey) {
p->encrypted = true; p->encrypted = true;
} }
@ -192,7 +192,7 @@ Profile* Profile::createProfile(QString name, QString password)
Settings::getInstance().createPersonal(name); Settings::getInstance().createPersonal(name);
Profile* p = new Profile(name, password, true, QByteArray()); Profile* p = new Profile(name, password, true, QByteArray());
p->passkey = std::move(tmpKey); p->passkey = std::move(tmpKey);
if (tmpKey) { if (p->passkey) {
p->encrypted = true; p->encrypted = true;
} }
@ -393,10 +393,10 @@ QPixmap Profile::loadAvatar(const QString& ownerId)
QByteArray Profile::loadAvatarData(const QString& ownerId) QByteArray Profile::loadAvatarData(const QString& ownerId)
{ {
QString path = avatarPath(ownerId); QString path = avatarPath(ownerId);
bool avatarEncrypted = encrypted;
// If the encrypted avatar isn't found, try loading the unencrypted one for the same ID // If the encrypted avatar isn't found, try loading the unencrypted one for the same ID
if (encrypted && !QFile::exists(path)) { if (avatarEncrypted && !QFile::exists(path)) {
encrypted = false; avatarEncrypted = false;
path = avatarPath(ownerId, true); path = avatarPath(ownerId, true);
} }
@ -406,7 +406,7 @@ QByteArray Profile::loadAvatarData(const QString& ownerId)
} }
QByteArray pic = file.readAll(); QByteArray pic = file.readAll();
if (encrypted && !pic.isEmpty()) { if (avatarEncrypted && !pic.isEmpty()) {
pic = passkey->decrypt(pic); pic = passkey->decrypt(pic);
} }