From 39a227d88a3bfaab32b18e4bb961948864085f11 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 8 Nov 2023 19:15:04 +0300 Subject: =?UTF-8?q?fixes=20#3859=20(SecureIM:=20=D0=BF=D0=B5=D1=80=D0=B5?= =?UTF-8?q?=D0=B2=D0=BE=D0=B4=20=D0=BD=D0=B5=20=D0=BF=D0=BE=D0=BC=D0=B5?= =?UTF-8?q?=D1=89=D0=B0=D0=B5=D1=82=D1=81=D1=8F)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/SecureIM/src/commonheaders.cpp | 4 +--- plugins/SecureIM/src/commonheaders.h | 2 +- plugins/SecureIM/src/options.cpp | 4 ---- plugins/SecureIM/src/resource.h | 1 - plugins/SecureIM/src/secureim.h | 29 +------------------------ plugins/SecureIM/src/svcs_proto.cpp | 39 +++++++++++++++++++++++++--------- 6 files changed, 32 insertions(+), 47 deletions(-) (limited to 'plugins/SecureIM/src') diff --git a/plugins/SecureIM/src/commonheaders.cpp b/plugins/SecureIM/src/commonheaders.cpp index db6b01fe01..f94021d506 100644 --- a/plugins/SecureIM/src/commonheaders.cpp +++ b/plugins/SecureIM/src/commonheaders.cpp @@ -17,7 +17,7 @@ HANDLE g_IEC[1 + IEC_CNT*MODE_CNT]; int iBmpDepth; BOOL bPGPloaded = false, bPGPkeyrings = false, bUseKeyrings = false, bPGPprivkey = false; BOOL bGPGloaded = false, bGPGkeyrings = false, bSavePass = false; -BOOL bSFT, bSOM, bASI, bMCD, bSCM, bDGP, bAIP, bNOL, bAAK, bMCM; +BOOL bSFT, bSOM, bASI, bMCD, bSCM, bAIP, bNOL, bAAK, bMCM; uint8_t bPGP, bGPG; mir_cs localQueueMutex; @@ -49,7 +49,6 @@ void GetFlags() bASI = g_plugin.getByte("asi", 0); bMCD = g_plugin.getByte("mcd", 0); bSCM = g_plugin.getByte("scm", 0); - bDGP = g_plugin.getByte("dgp", 0); bAIP = g_plugin.getByte("aip", 0); bNOL = g_plugin.getByte("nol", 0); bAAK = g_plugin.getByte("aak", 0); @@ -63,7 +62,6 @@ void SetFlags() g_plugin.setByte("asi", bASI); g_plugin.setByte("mcd", bMCD); g_plugin.setByte("scm", bSCM); - g_plugin.setByte("dgp", bDGP); g_plugin.setByte("aip", bAIP); g_plugin.setByte("nol", bNOL); g_plugin.setByte("aak", bAAK); diff --git a/plugins/SecureIM/src/commonheaders.h b/plugins/SecureIM/src/commonheaders.h index 60839f80b7..32a5d602a4 100644 --- a/plugins/SecureIM/src/commonheaders.h +++ b/plugins/SecureIM/src/commonheaders.h @@ -85,7 +85,7 @@ extern HANDLE g_IEC[1+IEC_CNT*MODE_CNT]; extern int iBmpDepth; extern BOOL bPGPloaded, bPGPkeyrings, bUseKeyrings, bPGPprivkey; extern BOOL bGPGloaded, bGPGkeyrings, bSavePass; -extern BOOL bSFT, bSOM, bASI, bMCD, bSCM, bDGP, bAIP, bNOL, bAAK, bMCM; +extern BOOL bSFT, bSOM, bASI, bMCD, bSCM, bAIP, bNOL, bAAK, bMCM; extern uint8_t bPGP, bGPG; extern mir_cs localQueueMutex; diff --git a/plugins/SecureIM/src/options.cpp b/plugins/SecureIM/src/options.cpp index a04e991ea7..9fe86edcda 100644 --- a/plugins/SecureIM/src/options.cpp +++ b/plugins/SecureIM/src/options.cpp @@ -400,7 +400,6 @@ static void ResetGeneralDlg(HWND hDlg) CheckDlgButton(hDlg, IDC_ASI, BST_UNCHECKED); CheckDlgButton(hDlg, IDC_MCD, BST_UNCHECKED); CheckDlgButton(hDlg, IDC_SCM, BST_UNCHECKED); - CheckDlgButton(hDlg, IDC_DGP, BST_UNCHECKED); CheckDlgButton(hDlg, IDC_AIP, BST_UNCHECKED); CheckDlgButton(hDlg, IDC_MCM, BST_UNCHECKED); @@ -468,7 +467,6 @@ static void RefreshGeneralDlg(HWND hDlg, BOOL iInit) CheckDlgButton(hDlg, IDC_ASI, (bASI) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hDlg, IDC_MCD, (bMCD) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hDlg, IDC_SCM, (bSCM) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hDlg, IDC_DGP, (bDGP) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hDlg, IDC_AIP, (bAIP) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hDlg, IDC_NOL, (bNOL) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hDlg, IDC_AAK, (bAAK) ? BST_CHECKED : BST_UNCHECKED); @@ -578,7 +576,6 @@ static void ApplyGeneralSettings(HWND hDlg) bASI = (IsDlgButtonChecked(hDlg, IDC_ASI) == BST_CHECKED); bMCD = (IsDlgButtonChecked(hDlg, IDC_MCD) == BST_CHECKED); bSCM = (IsDlgButtonChecked(hDlg, IDC_SCM) == BST_CHECKED); - bDGP = (IsDlgButtonChecked(hDlg, IDC_DGP) == BST_CHECKED); bAIP = (IsDlgButtonChecked(hDlg, IDC_AIP) == BST_CHECKED); bNOL = (IsDlgButtonChecked(hDlg, IDC_NOL) == BST_CHECKED); bAAK = (IsDlgButtonChecked(hDlg, IDC_AAK) == BST_CHECKED); @@ -815,7 +812,6 @@ static INT_PTR CALLBACK DlgProcOptionsGeneral(HWND hDlg, UINT wMsg, WPARAM wPara case IDC_MCD: case IDC_KET: case IDC_SCM: - case IDC_DGP: case IDC_OKT: break; diff --git a/plugins/SecureIM/src/resource.h b/plugins/SecureIM/src/resource.h index 79f9a8ed5b..0464a7ac0f 100644 --- a/plugins/SecureIM/src/resource.h +++ b/plugins/SecureIM/src/resource.h @@ -81,7 +81,6 @@ #define IDC_EDIT1 1041 #define IDC_EDIT2 1042 #define IDC_SCM 1043 -#define IDC_DGP 1044 #define IDC_OKT 1045 #define IDC_AIP 1046 #define IDC_SPLITON 1048 diff --git a/plugins/SecureIM/src/secureim.h b/plugins/SecureIM/src/secureim.h index 41f9f40cad..ddbf44feec 100644 --- a/plugins/SecureIM/src/secureim.h +++ b/plugins/SecureIM/src/secureim.h @@ -33,7 +33,6 @@ #define SiG_SECP 12 #define SiG_PGPM 13 #define SiG_NONE -1 -#define SiG_GAME -2 struct SIG { char *sig; @@ -41,33 +40,7 @@ struct SIG { char key; }; -const SIG signs[] = { - {"----Key3@hell----", 17, SiG_KEYR}, - {"----Key4@hell----", 17, SiG_KEYR}, - {"----Secured@hell----", 20, SiG_ENON}, - {"----Offline@hell----", 20, SiG_ENOF}, - {"----Resend@hell----", 19, SiG_RSND}, - {"----INIT@HELL----", 17, SiG_INIT}, - {"----DEINIT@HELL----", 19, SiG_DEIN}, - {"----DISABLED@HELL----", 21, SiG_DISA}, - {"----FAKE@HELL----", 17, SiG_FAKE}, - {"----KeyA@hell----", 17, SiG_KEYA}, - {"----KeyB@hell----", 17, SiG_KEYB}, - {"----Part@hell----", 17, SiG_PART}, - {"[SECURE]", 8, SiG_SECU}, - {"[$ECURE]", 8, SiG_SECP}, - {"-----BEGIN PGP MESSAGE-----", 27, SiG_PGPM}, - {"@@BattleShip", 12, SiG_GAME}, - {"GoMoku 0.0.2.2:", 15, SiG_GAME}, - {"@@GoMoku", 8, SiG_GAME}, - {"pbiChess:", 9, SiG_GAME}, - {"pbiReverse:", 11, SiG_GAME}, - {"pbiCorners:", 11, SiG_GAME}, - {"pbiCheckersInt:", 15, SiG_GAME}, - {"pbiCheckersRus:", 15, SiG_GAME}, - {"pbiCheckersPool:", 16, SiG_GAME}, - {0} -}; +extern const SIG signs[]; #define SIG_KEY3 signs[ 0].sig #define SIG_KEY4 signs[ 1].sig diff --git a/plugins/SecureIM/src/svcs_proto.cpp b/plugins/SecureIM/src/svcs_proto.cpp index f1819c0b29..d1079c8276 100644 --- a/plugins/SecureIM/src/svcs_proto.cpp +++ b/plugins/SecureIM/src/svcs_proto.cpp @@ -1,16 +1,35 @@ #include "commonheaders.h" +const SIG signs[] = { + {"----Key3@hell----", 17, SiG_KEYR}, + {"----Key4@hell----", 17, SiG_KEYR}, + {"----Secured@hell----", 20, SiG_ENON}, + {"----Offline@hell----", 20, SiG_ENOF}, + {"----Resend@hell----", 19, SiG_RSND}, + {"----INIT@HELL----", 17, SiG_INIT}, + {"----DEINIT@HELL----", 19, SiG_DEIN}, + {"----DISABLED@HELL----", 21, SiG_DISA}, + {"----FAKE@HELL----", 17, SiG_FAKE}, + {"----KeyA@hell----", 17, SiG_KEYA}, + {"----KeyB@hell----", 17, SiG_KEYB}, + {"----Part@hell----", 17, SiG_PART}, + {"[SECURE]", 8, SiG_SECU}, + {"[$ECURE]", 8, SiG_SECP}, + {"-----BEGIN PGP MESSAGE-----", 27, SiG_PGPM}, +}; + // return SignID int getSecureSig(LPCSTR szMsg, LPSTR *szPlainMsg = nullptr) { - if (szPlainMsg) *szPlainMsg = (LPSTR)szMsg; - for (int i = 0; signs[i].len; i++) { - if (memcmp(szMsg, signs[i].sig, signs[i].len) == 0) { - if (szPlainMsg) *szPlainMsg = (LPSTR)(szMsg + signs[i].len); - if (signs[i].key == SiG_GAME && !bDGP) - return SiG_NONE; - - return signs[i].key; + if (szPlainMsg) + *szPlainMsg = (LPSTR)szMsg; + + for (auto &it: signs) { + if (memcmp(szMsg, it.sig, it.len) == 0) { + if (szPlainMsg) + *szPlainMsg = (LPSTR)(szMsg + it.len); + + return it.key; } } return SiG_NONE; @@ -59,7 +78,7 @@ INT_PTR __cdecl onRecvMsg(WPARAM wParam, LPARAM lParam) bool bGPG = isContactGPG(ccs->hContact); // pass any unchanged message - if (!ptr || ssig == SiG_GAME || !isSecureProtocol(ccs->hContact) || + if (!ptr || !isSecureProtocol(ccs->hContact) || (db_mc_isMeta(ccs->hContact) && (ccs->wParam & PREF_SIMNOMETA)) || isChatRoom(ccs->hContact) || (ssig == SiG_NONE && !ptr->msgSplitted && !bSecured && !bPGP && !bGPG)) { Sent_NetLog("onRecvMsg: pass unhandled"); @@ -456,7 +475,7 @@ INT_PTR __cdecl onSendMsg(WPARAM wParam, LPARAM lParam) Sent_NetLog("onSend: %s", (LPSTR)ccs->lParam); // pass unhandled messages - if (!ptr || ssig == SiG_GAME || ssig == SiG_PGPM || ssig == SiG_SECU || ssig == SiG_SECP || + if (!ptr || ssig == SiG_PGPM || ssig == SiG_SECU || ssig == SiG_SECP || isChatRoom(ccs->hContact) || stat == -1 || (ssig == SiG_NONE && ptr->sendQueue) || (ssig == SiG_NONE && ptr->status == STATUS_DISABLED)) { Sent_NetLog("onSendMsg: pass unhandled"); -- cgit v1.2.3