summaryrefslogtreecommitdiff
path: root/protocols/Tox/src/tox_profile.cpp
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2015-04-14 20:32:40 +0000
committerAlexander Lantsev <aunsane@gmail.com>2015-04-14 20:32:40 +0000
commit4d0735ab834be6c541e7e577fbe76c888bf4d09f (patch)
tree8e290ade50e86e7b5f53a2b66bb0f1f2a2119982 /protocols/Tox/src/tox_profile.cpp
parent31ba819bd0994a0a48a174cba37b5985522ff3f8 (diff)
Tox: second approach for audio support
git-svn-id: http://svn.miranda-ng.org/main/trunk@12827 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Tox/src/tox_profile.cpp')
-rw-r--r--protocols/Tox/src/tox_profile.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/protocols/Tox/src/tox_profile.cpp b/protocols/Tox/src/tox_profile.cpp
index 2affb68422..afbf5f577e 100644
--- a/protocols/Tox/src/tox_profile.cpp
+++ b/protocols/Tox/src/tox_profile.cpp
@@ -65,13 +65,16 @@ bool CToxProto::LoadToxProfile(Tox_Options *options)
return false;
}
}
+ uint8_t *encryptedData = (uint8_t*)mir_calloc(size - TOX_PASS_ENCRYPTION_EXTRA_LENGTH);
TOX_ERR_DECRYPTION coreDecryptError;
- if (!tox_pass_decrypt(data, size, (uint8_t*)password, mir_strlen(password), data, &coreDecryptError))
+ if (!tox_pass_decrypt(data, size, (uint8_t*)password, mir_strlen(password), encryptedData, &coreDecryptError))
{
debugLogA(__FUNCTION__": failed to load tox profile (%d)", coreDecryptError);
mir_free(data);
return false;
}
+ mir_free(data);
+ data = encryptedData;
size -= TOX_PASS_ENCRYPTION_EXTRA_LENGTH;
}
@@ -94,10 +97,11 @@ void CToxProto::SaveToxProfile()
uint8_t *data = (uint8_t*)mir_calloc(size + TOX_PASS_ENCRYPTION_EXTRA_LENGTH);
tox_get_savedata(tox, data);
- if (password && strlen(password))
+ size_t passwordLen = mir_strlen(password);
+ if (password && passwordLen)
{
TOX_ERR_ENCRYPTION coreEncryptError;
- if (!tox_pass_encrypt(data, size, (uint8_t*)password, strlen(password), data, &coreEncryptError))
+ if (!tox_pass_encrypt(data, size, (uint8_t*)password, passwordLen, data, &coreEncryptError))
{
debugLogA(__FUNCTION__": failed to encrypt tox profile");
mir_free(data);