mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
fix(warnings): fix some warnings about the stack protector not working
This commit is contained in:
parent
fe53b01eb3
commit
e7276e7b43
|
@ -870,11 +870,14 @@ QPair<QByteArray, QByteArray> Core::getKeypair() const
|
|||
if (!tox)
|
||||
return keypair;
|
||||
|
||||
char buf[std::max(TOX_PUBLIC_KEY_SIZE, TOX_SECRET_KEY_SIZE)];
|
||||
tox_self_get_public_key(tox, (uint8_t*)buf);
|
||||
keypair.first = QByteArray(buf, TOX_PUBLIC_KEY_SIZE);
|
||||
tox_self_get_secret_key(tox, (uint8_t*)buf);
|
||||
keypair.second = QByteArray(buf, TOX_SECRET_KEY_SIZE);
|
||||
QByteArray pk(TOX_PUBLIC_KEY_SIZE, 0x00);
|
||||
QByteArray sk(TOX_SECRET_KEY_SIZE, 0x00);
|
||||
|
||||
tox_self_get_public_key(tox, (uint8_t*) pk.data());
|
||||
tox_self_get_secret_key(tox, (uint8_t*) sk.data());
|
||||
|
||||
keypair.first = pk;
|
||||
keypair.second = sk;
|
||||
return keypair;
|
||||
}
|
||||
|
||||
|
|
|
@ -64,14 +64,14 @@ QByteArray Core::encryptData(const QByteArray &data)
|
|||
|
||||
QByteArray Core::encryptData(const QByteArray& data, const Tox_Pass_Key& encryptionKey)
|
||||
{
|
||||
uint8_t encrypted[data.size() + TOX_PASS_ENCRYPTION_EXTRA_LENGTH];
|
||||
QByteArray encrypted(data.size() + TOX_PASS_ENCRYPTION_EXTRA_LENGTH, 0x00);
|
||||
if (!tox_pass_key_encrypt(&encryptionKey, reinterpret_cast<const uint8_t*>(data.data()), data.size(),
|
||||
encrypted, nullptr))
|
||||
(uint8_t*) encrypted.data(), nullptr))
|
||||
{
|
||||
qWarning() << "Encryption failed";
|
||||
return QByteArray();
|
||||
}
|
||||
return QByteArray(reinterpret_cast<char*>(encrypted), data.size() + TOX_PASS_ENCRYPTION_EXTRA_LENGTH);
|
||||
return encrypted;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -89,18 +89,18 @@ QByteArray Core::decryptData(const QByteArray& data, const Tox_Pass_Key& encrypt
|
|||
{
|
||||
if (data.size() < TOX_PASS_ENCRYPTION_EXTRA_LENGTH)
|
||||
{
|
||||
qWarning() << "Not enough data:"<<data.size();
|
||||
qWarning() << "Not enough data:" << data.size();
|
||||
return QByteArray();
|
||||
}
|
||||
int sz = data.size() - TOX_PASS_ENCRYPTION_EXTRA_LENGTH;
|
||||
uint8_t decrypted[sz];
|
||||
int decryptedSize = data.size() - TOX_PASS_ENCRYPTION_EXTRA_LENGTH;
|
||||
QByteArray decrypted(decryptedSize, 0x00);
|
||||
if (!tox_pass_key_decrypt(&encryptionKey, reinterpret_cast<const uint8_t*>(data.data()), data.size(),
|
||||
decrypted, nullptr))
|
||||
(uint8_t*) decrypted.data(), nullptr))
|
||||
{
|
||||
qWarning() << "Decryption failed";
|
||||
return QByteArray();
|
||||
}
|
||||
return QByteArray(reinterpret_cast<char*>(decrypted), sz);
|
||||
return decrypted;
|
||||
}
|
||||
|
||||
QByteArray Core::getSaltFromFile(QString filename)
|
||||
|
|
Loading…
Reference in New Issue
Block a user