From d8a969bd605c890cffabb71d3e7dfac8855a6045 Mon Sep 17 00:00:00 2001 From: Alexander Gluzsky Date: Fri, 17 Aug 2012 23:55:14 +0000 Subject: fixed possible memmory corruptions git-svn-id: http://svn.miranda-ng.org/main/trunk@1492 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/New_GPG/src/messages.cpp | 62 +++++++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 27 deletions(-) (limited to 'plugins/New_GPG/src/messages.cpp') diff --git a/plugins/New_GPG/src/messages.cpp b/plugins/New_GPG/src/messages.cpp index ba9a36c29c..f551680c36 100755 --- a/plugins/New_GPG/src/messages.cpp +++ b/plugins/New_GPG/src/messages.cpp @@ -25,7 +25,7 @@ int returnNoError(HANDLE hContact); std::list sent_msgs; -int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags, DWORD timestamp) +void RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags, DWORD timestamp) { DWORD dbflags = DBEF_UTF; { //check for gpg related data @@ -69,7 +69,7 @@ int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags, D { HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags)); - return 0; + return; } } { @@ -169,13 +169,13 @@ int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags, D CallContactService(hContact, PSS_MESSAGE, (WPARAM)PREF_UTF, (LPARAM)"Unable to decrypt PGP encrypted message"); HistoryLog(hContact, db_event("Error message sent", 0, 0, DBEF_SENT)); DBWriteContactSettingByte(hContact, szGPGModuleName, "GPGEncryption", enc); - return 0; + return; } if(result == pxNotFound) { DeleteFile(path.c_str()); HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags)); - return 0; + return; } //TODO: check gpg output for errors _terminate = false; @@ -233,13 +233,13 @@ int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags, D CallContactService(hContact, PSS_MESSAGE, (WPARAM)PREF_UTF, (LPARAM)"Unable to decrypt PGP encrypted message"); HistoryLog(hContact, db_event("Error message sent", 0, 0, DBEF_SENT)); DBWriteContactSettingByte(hContact, szGPGModuleName, "GPGEncryption", enc); - return 0; + return; } if(result == pxNotFound) { DeleteFile(path.c_str()); HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags)); - return 0; + return; } //TODO: check gpg output for errors } @@ -258,7 +258,7 @@ int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags, D CallContactService(hContact, PSS_MESSAGE, (WPARAM)PREF_UTF, (LPARAM)"Unable to decrypt PGP encrypted message"); HistoryLog(hContact, db_event("Error message sent", 0, 0, DBEF_SENT)); DBWriteContactSettingByte(hContact, szGPGModuleName, "GPGEncryption", enc); - return 0; + return; } if(result == pxNotFound) { @@ -292,7 +292,7 @@ int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags, D HistoryLog(hContact, db_event("Error message sent", 0, 0, DBEF_SENT)); DBWriteContactSettingByte(hContact, szGPGModuleName, "GPGEncryption", enc); mir_free(tmp); - return 0; + return; } } } @@ -329,7 +329,7 @@ int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags, D HistoryLog(hContact, db_event("Error message sent", 0, 0, DBEF_SENT)); DBWriteContactSettingByte(hContact, szGPGModuleName, "GPGEncryption", enc); mir_free(tmp); - return 0; + return; } else { @@ -344,12 +344,12 @@ int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags, D HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags|DBEF_READ)); HistoryLog(metaGetContact(hContact), db_event(msg, timestamp, 0, dbflags)); mir_free(msg); - return 0; + return; } char *tmp = mir_strdup(toUTF8(str).c_str()); HistoryLog(hContact, db_event(tmp, timestamp, 0, dbflags)); mir_free(tmp); - return 0; + return; } } } @@ -361,13 +361,13 @@ int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags, D { HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags|DBEF_READ)); HistoryLog(metaGetContact(hContact), db_event(msg, timestamp, 0, dbflags)); - return 0; + return; } HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags|DBEF_READ)); - return 0; + return; } HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags)); - return 0; + return; } int RecvMsgSvc(WPARAM w, LPARAM l) @@ -621,7 +621,7 @@ int RecvMsgSvc(WPARAM w, LPARAM l) return returnNoError(ccs->hContact); } -int SendMsgSvc_func(HANDLE hContact, char *msg, DWORD flags) +void SendMsgSvc_func(HANDLE hContact, char *msg, DWORD flags) { wstring str; bool isansi = false; @@ -668,7 +668,8 @@ int SendMsgSvc_func(HANDLE hContact, char *msg, DWORD flags) HistoryLog(hContact, db_event("Failed to encrypt message with GPG", 0,0, DBEF_SENT)); hcontact_data[hContact].msgs_to_pass.push_back("Failed to encrypt message with GPG"); mir_free(msg); - return CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)msg); + CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)msg); + return; } if(!bJabberAPI || !bIsMiranda09) //force jabber to handle encrypted message by itself cmd += _T("--comment \"\" --no-version "); @@ -714,12 +715,14 @@ int SendMsgSvc_func(HANDLE hContact, char *msg, DWORD flags) params.hProcess = NULL; debuglog<hContact, msg, (DWORD)ccs->wParam)); - return returnNoError(ccs->hContact); + boost::thread *thr = new boost::thread(boost::bind(SendMsgSvc_func, ccs->hContact, msg, (DWORD)ccs->wParam)); + return returnNoError(ccs->hContact); } boost::mutex event_processing_mutex; -- cgit v1.2.3