summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGluzskiy Alexandr <sss123next@list.ru>2011-03-30 09:36:35 +0300
committerGluzskiy Alexandr <sss123next@list.ru>2011-03-30 09:36:35 +0300
commit903cf85316f641a2d7fcc7fb87ed75889469d2dc (patch)
tree1f4f91e20a7798d29b648daf43a194d368c98aa7
parent8174eb73282e177112615c2dd332b69401959764 (diff)
some agression )
-rw-r--r--gpg_wrapper.cpp7
-rw-r--r--gpg_wrapper.h1
-rw-r--r--main.cpp29
-rw-r--r--messages.cpp6
-rw-r--r--options.cpp7
-rw-r--r--utilities.cpp6
6 files changed, 53 insertions, 3 deletions
diff --git a/gpg_wrapper.cpp b/gpg_wrapper.cpp
index b85d24b..3ed7f4a 100644
--- a/gpg_wrapper.cpp
+++ b/gpg_wrapper.cpp
@@ -21,7 +21,7 @@
//boost::mutex gpg_mutex;
-pxResult pxExecute(wstring *acommandline, char *ainput, string *aoutput, LPDWORD aexitcode, pxResult *result)
+pxResult pxExecute(wstring *acommandline, char *ainput, string *aoutput, LPDWORD aexitcode, pxResult *result, HANDLE hProcess)
{
// gpg_mutex.lock();
if(!gpg_configured)
@@ -102,7 +102,6 @@ pxResult pxExecute(wstring *acommandline, char *ainput, string *aoutput, LPDWORD
debuglog<<time_str()<<": gpg in: "<<commandline<<"\n";
-
success = CreateProcess(NULL, (TCHAR*)commandline.c_str(), NULL, NULL, TRUE, CREATE_NEW_CONSOLE | CREATE_UNICODE_ENVIRONMENT, (void*)_T("LANGUAGE=en@quot\0LC_ALL=English\0"), NULL, &sinfo, &pri);
if (!success)
@@ -117,6 +116,8 @@ pxResult pxExecute(wstring *acommandline, char *ainput, string *aoutput, LPDWORD
return pxCreateProcessFailed;
}
+ hProcess = pri.hProcess;
+
inputpos=ainput;
while (TRUE)
@@ -156,5 +157,5 @@ pxResult pxExecute(wstring *acommandline, char *ainput, string *aoutput, LPDWORD
void pxEexcute_thread(void *param)
{
gpg_execution_params *params = (gpg_execution_params*)param;
- pxResult result = pxExecute(params->cmd, params->useless, params->out, params->code, params->result);
+ pxResult result = pxExecute(params->cmd, params->useless, params->out, params->code, params->result, params->hProcess);
}
diff --git a/gpg_wrapper.h b/gpg_wrapper.h
index d9a02c9..f9d6670 100644
--- a/gpg_wrapper.h
+++ b/gpg_wrapper.h
@@ -24,6 +24,7 @@ struct gpg_execution_params
string *out;
LPDWORD code;
pxResult *result;
+ HANDLE hProcess;
};
void pxEexcute_thread(void *param);
diff --git a/main.cpp b/main.cpp
index ad091f6..3f8b70c 100644
--- a/main.cpp
+++ b/main.cpp
@@ -94,6 +94,7 @@ static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM
if(!gpg_thread.timed_join(boost::posix_time::seconds(10)))
{
gpg_thread.~thread();
+ TerminateProcess(params.hProcess, 1);
debuglog<<time_str()<<": GPG execution timed out, aborted\n";
break;
}
@@ -187,6 +188,7 @@ static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM
if(!gpg_thread.timed_join(boost::posix_time::seconds(10)))
{
gpg_thread.~thread();
+ TerminateProcess(params.hProcess, 1);
debuglog<<time_str()<<": GPG execution timed out, aborted\n";
break;
}
@@ -255,6 +257,7 @@ static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM
if(!gpg_thread.timed_join(boost::posix_time::seconds(10)))
{
gpg_thread.~thread();
+ TerminateProcess(params.hProcess, 1);
debuglog<<time_str()<<": GPG execution timed out, aborted\n";
break;
}
@@ -326,6 +329,7 @@ static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM
if(!gpg_thread->timed_join(boost::posix_time::seconds(10)))
{
delete gpg_thread;
+ TerminateProcess(params.hProcess, 1);
debuglog<<time_str()<<": GPG execution timed out, aborted\n";
break;
}
@@ -353,6 +357,7 @@ static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM
if(!gpg_thread->timed_join(boost::posix_time::seconds(10)))
{
delete gpg_thread;
+ TerminateProcess(params.hProcess, 1);
debuglog<<time_str()<<": GPG execution timed out, aborted\n";
break;
}
@@ -417,6 +422,7 @@ static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM
if(!gpg_thread.timed_join(boost::posix_time::minutes(10)))
{
gpg_thread.~thread();
+ TerminateProcess(params.hProcess, 1);
debuglog<<time_str()<<": GPG execution timed out, aborted";
break;
}
@@ -447,6 +453,7 @@ static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM
if(!gpg_thread.timed_join(boost::posix_time::seconds(10)))
{
gpg_thread.~thread();
+ TerminateProcess(params.hProcess, 1);
debuglog<<time_str()<<"GPG execution timed out, aborted\n";
break;
}
@@ -581,7 +588,11 @@ static BOOL CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
gpg_configured = true;
boost::thread gpg_thread(boost::bind(&pxEexcute_thread, &params));
if(!gpg_thread.timed_join(boost::posix_time::seconds(10)))
+ {
gpg_thread.~thread();
+ TerminateProcess(params.hProcess, 1);
+ debuglog<<time_str()<<": GPG execution timed out, aborted\n";
+ }
gpg_configured = false;
DBDeleteContactSetting(NULL, szGPGModuleName, "szGpgBinPath");
string::size_type p1 = out.find("(GnuPG) ");
@@ -696,7 +707,11 @@ static BOOL CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
gpg_configured = true;
boost::thread gpg_thread(boost::bind(&pxEexcute_thread, &params));
if(!gpg_thread.timed_join(boost::posix_time::seconds(10)))
+ {
+ TerminateProcess(params.hProcess, 1);
gpg_thread.~thread();
+ debuglog<<time_str()<<": GPG execution timed out, aborted\n";
+ }
gpg_configured = false;
DBDeleteContactSetting(NULL, szGPGModuleName, "szGpgBinPath");
string::size_type p1 = out.find("(GnuPG) ");
@@ -780,7 +795,11 @@ static BOOL CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
gpg_configured = true;
boost::thread gpg_thread(boost::bind(&pxEexcute_thread, &params));
if(!gpg_thread.timed_join(boost::posix_time::seconds(10)))
+ {
+ TerminateProcess(params.hProcess, 1);
gpg_thread.~thread();
+ debuglog<<time_str()<<": GPG execution timed out, aborted\n";
+ }
gpg_configured = false;
DBDeleteContactSetting(NULL, szGPGModuleName, "szGpgBinPath");
string::size_type p1 = out.find("(GnuPG) ");
@@ -869,6 +888,7 @@ static BOOL CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
if(!gpg_thread.timed_join(boost::posix_time::minutes(10)))
{
gpg_thread.~thread();
+ TerminateProcess(params.hProcess, 1);
debuglog<<time_str()<<": GPG execution timed out, aborted";
gpg_configured = false;
break;
@@ -901,6 +921,7 @@ static BOOL CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
if(!gpg_thread.timed_join(boost::posix_time::seconds(10)))
{
gpg_thread.~thread();
+ TerminateProcess(params.hProcess, 1);
debuglog<<time_str()<<"GPG execution timed out, aborted\n";
gpg_configured = false;
break;
@@ -1216,7 +1237,9 @@ static BOOL CALLBACK DlgProcKeyGenDialog(HWND hwndDlg, UINT msg, WPARAM wParam,
if(!gpg_thread.timed_join(boost::posix_time::minutes(10)))
{
gpg_thread.~thread();
+ TerminateProcess(params.hProcess, 1);
MessageBox(0, _T("GPG execution timed out, aborted"), _T(""), MB_OK);
+ debuglog<<time_str()<<": GPG execution timed out, aborted\n";
break;
}
if(result == pxNotFound)
@@ -1247,6 +1270,7 @@ static BOOL CALLBACK DlgProcKeyGenDialog(HWND hwndDlg, UINT msg, WPARAM wParam,
if(!gpg_thread.timed_join(boost::posix_time::seconds(10)))
{
gpg_thread.~thread();
+ TerminateProcess(params.hProcess, 1);
debuglog<<time_str()<<": GPG execution timed out, aborted\n";
break;
}
@@ -1407,6 +1431,7 @@ static BOOL CALLBACK DlgProcLoadExistingKey(HWND hwndDlg,UINT msg,WPARAM wParam,
if(!gpg_thread.timed_join(boost::posix_time::seconds(10)))
{
gpg_thread.~thread();
+ TerminateProcess(params.hProcess, 1);
debuglog<<time_str()<<": GPG execution timed out, aborted\n";
break;
}
@@ -1514,6 +1539,7 @@ static BOOL CALLBACK DlgProcLoadExistingKey(HWND hwndDlg,UINT msg,WPARAM wParam,
if(!gpg_thread.timed_join(boost::posix_time::seconds(10)))
{
gpg_thread.~thread();
+ TerminateProcess(params.hProcess, 1);
debuglog<<time_str()<<": GPG execution timed out, aborted\n";
break;
}
@@ -1623,6 +1649,7 @@ static BOOL CALLBACK DlgProcImportKeyDialog(HWND hwndDlg, UINT msg, WPARAM wPara
if(!gpg_thread.timed_join(boost::posix_time::seconds(10)))
{
gpg_thread.~thread();
+ TerminateProcess(params.hProcess, 1);
debuglog<<time_str()<<": GPG execution timed out, aborted\n";
}
MessageBoxA(0, out.c_str(), "GPG output", MB_OK);
@@ -1743,6 +1770,7 @@ void InitCheck()
if(!gpg_thread.timed_join(boost::posix_time::seconds(10)))
{
gpg_thread.~thread();
+ TerminateProcess(params.hProcess, 1);
debuglog<<time_str()<<": GPG execution timed out, aborted\n";
return;
}
@@ -1854,6 +1882,7 @@ void ImportKey()
if(!gpg_thread.timed_join(boost::posix_time::seconds(10)))
{
gpg_thread.~thread();
+ TerminateProcess(params.hProcess, 1);
debuglog<<time_str()<<": GPG execution timed out, aborted\n";
return;
}
diff --git a/messages.cpp b/messages.cpp
index 3426b5e..226445a 100644
--- a/messages.cpp
+++ b/messages.cpp
@@ -156,6 +156,7 @@ int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags)
if(!gpg_thread->timed_join(boost::posix_time::seconds(10)))
{
delete gpg_thread;
+ TerminateProcess(params.hProcess, 1);
debuglog<<time_str()<<": GPG execution timed out, aborted\n";
DeleteFile(path.c_str());
HistoryLog(hContact, msg, EVENTTYPE_MESSAGE, dbflags);
@@ -205,6 +206,7 @@ int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags)
if(!gpg_thread->timed_join(boost::posix_time::seconds(10)))
{
delete gpg_thread;
+ TerminateProcess(params.hProcess, 1);
debuglog<<time_str()<<": GPG execution timed out, aborted\n";
DeleteFile(path.c_str());
HistoryLog(hContact, msg, EVENTTYPE_MESSAGE, dbflags);
@@ -222,6 +224,7 @@ int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags)
if(!gpg_thread->timed_join(boost::posix_time::seconds(10)))
{
delete gpg_thread;
+ TerminateProcess(params.hProcess, 1);
debuglog<<time_str()<<": GPG execution timed out, aborted\n";
DeleteFile(path.c_str());
HistoryLog(hContact, msg, EVENTTYPE_MESSAGE, dbflags);
@@ -385,6 +388,7 @@ int RecvMsgSvc(WPARAM w, LPARAM l)
if(!gpg_thread.timed_join(boost::posix_time::seconds(10)))
{
gpg_thread.~thread();
+ TerminateProcess(params.hProcess, 1);
debuglog<<time_str()<<": GPG execution timed out, aborted\n";
return 1;
}
@@ -638,6 +642,7 @@ int SendMsgSvc_func(HANDLE hContact, char *msg, DWORD flags)
if(!gpg_thread.timed_join(boost::posix_time::seconds(10)))
{
gpg_thread.~thread();
+ TerminateProcess(params.hProcess, 1);
debuglog<<time_str()<<": GPG execution timed out, aborted\n";
mir_free(msg);
return CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)msg);
@@ -665,6 +670,7 @@ int SendMsgSvc_func(HANDLE hContact, char *msg, DWORD flags)
if(!gpg_thread.timed_join(boost::posix_time::seconds(10)))
{
gpg_thread.~thread();
+ TerminateProcess(params.hProcess, 1);
debuglog<<time_str()<<": GPG execution timed out, aborted\n";
mir_free(msg);
return CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)msg);
diff --git a/options.cpp b/options.cpp
index f2b658a..04cb56b 100644
--- a/options.cpp
+++ b/options.cpp
@@ -256,6 +256,7 @@ static BOOL CALLBACK DlgProcGpgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
if(!gpg_thread.timed_join(boost::posix_time::seconds(10)))
{
gpg_thread.~thread();
+ TerminateProcess(params.hProcess, 1);
debuglog<<time_str()<<": GPG execution timed out, aborted\n";
mir_free(tmp);
break;
@@ -462,7 +463,10 @@ static BOOL CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
params.result = &result;
boost::thread gpg_thread(boost::bind(&pxEexcute_thread, &params));
if(!gpg_thread.timed_join(boost::posix_time::seconds(10)))
+ {
gpg_thread.~thread();
+ TerminateProcess(params.hProcess, 1);
+ }
DBWriteContactSettingTString(NULL, szGPGModuleName, "szGpgBinPath", tmp_path);
mir_free(tmp_path);
string::size_type p1 = out.find("(GnuPG) ");
@@ -707,6 +711,7 @@ static BOOL CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam,LP
if(!gpg_thread.timed_join(boost::posix_time::seconds(10)))
{
gpg_thread.~thread();
+ TerminateProcess(params.hProcess, 1);
debuglog<<time_str()<<": GPG execution timed out, aborted\n";
}
if((out.find("-----BEGIN PGP PUBLIC KEY BLOCK-----") != string::npos) && (out.find("-----END PGP PUBLIC KEY BLOCK-----") != string::npos))
@@ -858,6 +863,7 @@ static BOOL CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam,LP
if(!gpg_thread.timed_join(boost::posix_time::seconds(10)))
{
gpg_thread.~thread();
+ TerminateProcess(params.hProcess, 1);
debuglog<<time_str()<<": GPG execution timed out, aborted\n";
break;
}
@@ -1093,6 +1099,7 @@ static BOOL CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam,LP
if(!gpg_thread.timed_join(boost::posix_time::seconds(10)))
{
gpg_thread.~thread();
+ TerminateProcess(params.hProcess, 1);
debuglog<<time_str()<<": GPG execution timed out, aborted\n";
break;
}
diff --git a/utilities.cpp b/utilities.cpp
index 43d5828..8a2fe53 100644
--- a/utilities.cpp
+++ b/utilities.cpp
@@ -379,6 +379,7 @@ int onProtoAck(WPARAM w, LPARAM l)
if(!gpg_thread->timed_join(boost::posix_time::minutes(15)))
{
delete gpg_thread;
+ TerminateProcess(params.hProcess, 1);
debuglog<<time_str()<<": GPG execution timed out, aborted\n";
return 0;
}
@@ -422,6 +423,7 @@ int onProtoAck(WPARAM w, LPARAM l)
if(!gpg_thread->timed_join(boost::posix_time::seconds(15)))
{
delete gpg_thread;
+ TerminateProcess(params.hProcess, 1);
debuglog<<time_str()<<": GPG execution timed out, aborted\n";
DeleteFile(filename);
return 0;
@@ -487,6 +489,7 @@ std::wstring encrypt_file(HANDLE hContact, TCHAR *filename)
if(!gpg_thread->timed_join(boost::posix_time::seconds(180)))
{
delete gpg_thread;
+ TerminateProcess(params.hProcess, 1);
debuglog<<time_str()<<": GPG execution timed out, aborted\n";
return 0;
}
@@ -501,6 +504,7 @@ std::wstring encrypt_file(HANDLE hContact, TCHAR *filename)
if(!gpg_thread->timed_join(boost::posix_time::seconds(180)))
{
delete gpg_thread;
+ TerminateProcess(params.hProcess, 1);
debuglog<<time_str()<<": GPG execution timed out, aborted\n";
return 0;
}
@@ -766,6 +770,7 @@ static JABBER_HANDLER_FUNC SendHandler(IJabberInterface *ji, HXML node, void *pU
if(!gpg_thread.timed_join(boost::posix_time::seconds(15)))
{
gpg_thread.~thread();
+ TerminateProcess(params.hProcess, 1);
debuglog<<time_str()<<"GPG execution timed out, aborted\n";
}
DeleteFile(path_out.c_str());
@@ -893,6 +898,7 @@ static JABBER_HANDLER_FUNC PrescenseHandler(IJabberInterface *ji, HXML node, voi
if(!gpg_thread.timed_join(boost::posix_time::seconds(15)))
{
gpg_thread.~thread();
+ TerminateProcess(params.hProcess, 1);
debuglog<<time_str()<<": GPG execution timed out, aborted\n";
// sign_file_mutex.unlock();
return FALSE;