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

fix: remove unnecessary variable when checking whether save is a TES

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.
This commit is contained in:
Zetok Zalbavar 2016-12-08 18:00:05 +00:00
parent 3c71e5e2e1
commit 231e1d746a
No known key found for this signature in database
GPG Key ID: C953D3880212068A
2 changed files with 2 additions and 7 deletions

View File

@ -46,10 +46,6 @@
* *
* @var bool Profile::isRemoved * @var bool Profile::isRemoved
* @brief True if the profile has been removed by remove(). * @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; QVector<QString> Profile::profiles;
@ -631,7 +627,7 @@ bool Profile::isEncrypted() const
*/ */
bool Profile::isEncrypted(QString name) 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"; QString path = Settings::getInstance().getSettingsDirPath() + name + ".tox";
QFile saveFile(path); QFile saveFile(path);
if (!saveFile.open(QIODevice::ReadOnly)) if (!saveFile.open(QIODevice::ReadOnly))
@ -640,7 +636,7 @@ bool Profile::isEncrypted(QString name)
return false; return false;
} }
saveFile.read((char*)data, encryptHeaderSize); saveFile.read((char*)data, TOX_PASS_ENCRYPTION_EXTRA_LENGTH);
saveFile.close(); saveFile.close();
return tox_is_data_encrypted(data); return tox_is_data_encrypted(data);

View File

@ -98,7 +98,6 @@ private:
bool newProfile; bool newProfile;
bool isRemoved; bool isRemoved;
static QVector<QString> profiles; static QVector<QString> profiles;
static constexpr int encryptHeaderSize = 8;
}; };
#endif // PROFILE_H #endif // PROFILE_H