summaryrefslogtreecommitdiff
path: root/plugins/New_GPG/src/messages.cpp
diff options
context:
space:
mode:
authorAlexander Gluzsky <sss123next@list.ru>2012-08-17 23:55:14 +0000
committerAlexander Gluzsky <sss123next@list.ru>2012-08-17 23:55:14 +0000
commitd8a969bd605c890cffabb71d3e7dfac8855a6045 (patch)
tree0372a0e5e5a36c356640f427d3e8fae462b0f448 /plugins/New_GPG/src/messages.cpp
parent39b4c53fad33b800d53ebfe16634272ddd69b6c3 (diff)
fixed possible memmory corruptions
git-svn-id: http://svn.miranda-ng.org/main/trunk@1492 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/New_GPG/src/messages.cpp')
-rwxr-xr-xplugins/New_GPG/src/messages.cpp62
1 files changed, 35 insertions, 27 deletions
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<HANDLE> 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<<time_str()<<": GPG execution timed out, aborted\n";
mir_free(msg);
- return CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)msg);
+ CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)msg);
+ return;
}
if(result == pxNotFound)
{
mir_free(msg);
- return CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)msg);
+ CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)msg);
+ return;
}
//TODO: check gpg output for errors
if(out.find("There is no assurance this key belongs to the named user") != string::npos)
@@ -744,19 +747,21 @@ int SendMsgSvc_func(HANDLE hContact, char *msg, DWORD flags)
params.hProcess = NULL;
debuglog<<time_str()<<": GPG execution timed out, aborted\n";
mir_free(msg);
- return CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)msg);
+ CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)msg);
+ return;
}
if(result == pxNotFound)
{
mir_free(msg);
- return CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)msg);
+ CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)msg);
+ return;
}
//TODO: check gpg output for errors
}
else
{
mir_free(msg);
- return 0;
+ return;
}
}
if(out.find("usage: ") != string::npos)
@@ -764,7 +769,8 @@ int SendMsgSvc_func(HANDLE hContact, char *msg, DWORD flags)
MessageBox(0, _T("Something wrong, gpg does not understand us, aborting encryption."), _T("Warning"), MB_OK);
DeleteFile(path.c_str());
mir_free(msg);
- return CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)msg);
+ CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)msg);
+ return;
}
DeleteFile(path.c_str());
path.append(_T(".asc"));
@@ -790,7 +796,8 @@ int SendMsgSvc_func(HANDLE hContact, char *msg, DWORD flags)
hcontact_data[hContact].msgs_to_pass.push_back("Failed to encrypt message with GPG");
debuglog<<time_str()<<": info: Failed to encrypt message with GPG\n";
mir_free(msg);
- return CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)msg);
+ CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)msg);
+ return;
}
string str_event = msg;
if(bAppendTags)
@@ -810,9 +817,10 @@ int SendMsgSvc_func(HANDLE hContact, char *msg, DWORD flags)
HistoryLog(hContact, db_event((char*)str_event.c_str(), 0,0, dbflags|DBEF_SENT));
if(!(flags & PREF_UTF))
flags |= PREF_UTF;
- sent_msgs.push_back((HANDLE)CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)toUTF8(str).c_str()));
+ HANDLE hProcess = NULL;
+ sent_msgs.push_back(hProcess = (HANDLE)CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)toUTF8(str).c_str()));
mir_free(msg);
- return 0;
+ return;
}
int SendMsgSvc(WPARAM w, LPARAM l)
@@ -901,8 +909,8 @@ int SendMsgSvc(WPARAM w, LPARAM l)
mir_free(msg);
return CallService(MS_PROTO_CHAINSEND, w, l);
}
- boost::thread *thr = new boost::thread(boost::bind(SendMsgSvc_func, ccs->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;