summaryrefslogtreecommitdiff
path: root/protocols/Tox/src/tox_profile.cpp
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2015-09-10 11:58:58 +0000
committerAlexander Lantsev <aunsane@gmail.com>2015-09-10 11:58:58 +0000
commit510f938a5c6f0ee95ac0b36e56aced065228298e (patch)
tree19f907a09498b6f76a4b7aae6ee90a16bf693aa2 /protocols/Tox/src/tox_profile.cpp
parent86c868a76a5ba3d638b3b7302cd5401df06591d8 (diff)
Tox: tox pointers should store in PollingThread to avoid cross thread using
git-svn-id: http://svn.miranda-ng.org/main/trunk@15316 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Tox/src/tox_profile.cpp')
-rw-r--r--protocols/Tox/src/tox_profile.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/protocols/Tox/src/tox_profile.cpp b/protocols/Tox/src/tox_profile.cpp
index d6fff1c75d..82754c5d6c 100644
--- a/protocols/Tox/src/tox_profile.cpp
+++ b/protocols/Tox/src/tox_profile.cpp
@@ -59,7 +59,7 @@ bool CToxProto::LoadToxProfile(Tox_Options *options)
if (data && tox_is_data_encrypted(data))
{
- password = mir_utf8encodeW(ptrT(getTStringA("Password")));
+ pass_ptrA password(mir_utf8encodeW(pass_ptrT(getTStringA("Password"))));
if (password == NULL || mir_strlen(password) == 0)
{
CToxPasswordEditor passwordEditor(this);
@@ -71,7 +71,7 @@ bool CToxProto::LoadToxProfile(Tox_Options *options)
}
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), encryptedData, &coreDecryptError))
+ if (!tox_pass_decrypt(data, size, (uint8_t*)(char*)password, mir_strlen(password), encryptedData, &coreDecryptError))
{
ShowNotification(TranslateT("Unable to decrypt Tox profile"), MB_ICONERROR);
debugLogA(__FUNCTION__": failed to decrypt tox profile (%d)", coreDecryptError);
@@ -98,15 +98,18 @@ void CToxProto::SaveToxProfile()
{
mir_cslock locker(profileLock);
- size_t size = tox_get_savedata_size(tox);
+ if (!toxThread)
+ return;
+
+ size_t size = tox_get_savedata_size(toxThread->tox);
uint8_t *data = (uint8_t*)mir_calloc(size + TOX_PASS_ENCRYPTION_EXTRA_LENGTH);
- tox_get_savedata(tox, data);
+ tox_get_savedata(toxThread->tox, data);
- size_t passwordLen = mir_strlen(password);
- if (password && passwordLen)
+ pass_ptrA password(mir_utf8encodeW(pass_ptrT(getTStringA("Password"))));
+ if (password && mir_strlen(password))
{
TOX_ERR_ENCRYPTION coreEncryptError;
- if (!tox_pass_encrypt(data, size, (uint8_t*)password, passwordLen, data, &coreEncryptError))
+ if (!tox_pass_encrypt(data, size, (uint8_t*)(char*)password, mir_strlen(password), data, &coreEncryptError))
{
debugLogA(__FUNCTION__": failed to encrypt tox profile");
mir_free(data);
@@ -159,12 +162,9 @@ CToxPasswordEditor::CToxPasswordEditor(CToxProto *proto) :
void CToxPasswordEditor::OnOk(CCtrlButton*)
{
- ptrT tszPassword(password.GetText());
+ pass_ptrT tszPassword(password.GetText());
if (savePermanently.Enabled())
m_proto->setTString("Password", tszPassword);
- if (m_proto->password != NULL)
- mir_free(m_proto->password);
- m_proto->password = mir_utf8encodeW(tszPassword);
EndDialog(m_hwnd, 1);
}