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

Commit

Permalink
fix: remove unnecessary variable when checking whether save is a TES
Browse files Browse the repository at this point in the history
There is a reason why magic length is not exposed via TES header –
knowing it is not needed. Client should check whether file is a TES with
a define that is provided in the public API.
  • Loading branch information
zetok committed Dec 9, 2016
1 parent 3c71e5e commit 231e1d7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
8 changes: 2 additions & 6 deletions src/persistence/profile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@
*
* @var bool Profile::isRemoved
* @brief True if the profile has been removed by remove().
*
* @var static constexpr int Profile::encryptHeaderSize = 8
* @brief How much data we need to read to check if the file is encrypted.
* @note Must be >= TOX_ENC_SAVE_MAGIC_LENGTH (8), which isn't publicly defined.
*/

QVector<QString> Profile::profiles;
Expand Down Expand Up @@ -631,7 +627,7 @@ bool Profile::isEncrypted() const
*/
bool Profile::isEncrypted(QString name)
{
uint8_t data[encryptHeaderSize] = {0};
uint8_t data[TOX_PASS_ENCRYPTION_EXTRA_LENGTH] = {0};
QString path = Settings::getInstance().getSettingsDirPath() + name + ".tox";
QFile saveFile(path);
if (!saveFile.open(QIODevice::ReadOnly))
Expand All @@ -640,7 +636,7 @@ bool Profile::isEncrypted(QString name)
return false;
}

saveFile.read((char*)data, encryptHeaderSize);
saveFile.read((char*)data, TOX_PASS_ENCRYPTION_EXTRA_LENGTH);
saveFile.close();

return tox_is_data_encrypted(data);
Expand Down
1 change: 0 additions & 1 deletion src/persistence/profile.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ private slots:
bool newProfile;
bool isRemoved;
static QVector<QString> profiles;
static constexpr int encryptHeaderSize = 8;
};

#endif // PROFILE_H

0 comments on commit 231e1d7

Please sign in to comment.