From 4d0735ab834be6c541e7e577fbe76c888bf4d09f Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Tue, 14 Apr 2015 20:32:40 +0000 Subject: Tox: second approach for audio support git-svn-id: http://svn.miranda-ng.org/main/trunk@12827 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Tox/src/tox_profile.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'protocols/Tox/src/tox_profile.cpp') 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); -- cgit v1.2.3