Skip to content
This repository has been archived by the owner on Feb 12, 2023. It is now read-only.

Commit

Permalink
fix(profile): toxsave wasn't correctly encrypted
Browse files Browse the repository at this point in the history
fix #4344
  • Loading branch information
sudden6 committed Apr 23, 2017
1 parent 52617ad commit 5b31cf6
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/persistence/profile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ Profile* Profile::loadProfile(QString name, const QString& password)
saveFile.close();
p = new Profile(name, password, false, data);
p->passkey = std::move(tmpKey);
if (tmpKey) {
if (p->passkey) {
p->encrypted = true;
}

Expand Down Expand Up @@ -192,7 +192,7 @@ Profile* Profile::createProfile(QString name, QString password)
Settings::getInstance().createPersonal(name);
Profile* p = new Profile(name, password, true, QByteArray());
p->passkey = std::move(tmpKey);
if (tmpKey) {
if (p->passkey) {
p->encrypted = true;
}

Expand Down Expand Up @@ -393,10 +393,10 @@ QPixmap Profile::loadAvatar(const QString& ownerId)
QByteArray Profile::loadAvatarData(const QString& 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 (encrypted && !QFile::exists(path)) {
encrypted = false;
if (avatarEncrypted && !QFile::exists(path)) {
avatarEncrypted = false;
path = avatarPath(ownerId, true);
}

Expand All @@ -406,7 +406,7 @@ QByteArray Profile::loadAvatarData(const QString& ownerId)
}

QByteArray pic = file.readAll();
if (encrypted && !pic.isEmpty()) {
if (avatarEncrypted && !pic.isEmpty()) {
pic = passkey->decrypt(pic);
}

Expand Down

0 comments on commit 5b31cf6

Please sign in to comment.