From d6e05cc3bca53565d9ca65377ab8b0b6190774b3 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 19 Nov 2013 18:01:14 +0000 Subject: preparing to the transparent cyphering: end of MS_DB_CRYPT_ENCODESTRING/MS_DB_CRYPT_DECODESTRING git-svn-id: http://svn.miranda-ng.org/main/trunk@6938 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/IcqOscarJ/src/changeinfo/upload.cpp | 23 ++--- protocols/IcqOscarJ/src/icq_firstrun.cpp | 53 +++++------ protocols/IcqOscarJ/src/icq_opts.cpp | 123 +++++++++++--------------- protocols/IcqOscarJ/src/utilities.cpp | 5 +- 4 files changed, 84 insertions(+), 120 deletions(-) (limited to 'protocols/IcqOscarJ/src') diff --git a/protocols/IcqOscarJ/src/changeinfo/upload.cpp b/protocols/IcqOscarJ/src/changeinfo/upload.cpp index 8e562b80f0..b619f099e2 100644 --- a/protocols/IcqOscarJ/src/changeinfo/upload.cpp +++ b/protocols/IcqOscarJ/src/changeinfo/upload.cpp @@ -36,7 +36,8 @@ int CIcqProto::StringToListItemId(const char *szSetting,int def) if (!strcmpnull(szSetting,setting[i].szDbSetting)) break; - if (i==settingCount) return def; + if (i == settingCount) + return def; FieldNamesItem *list = (FieldNamesItem*)setting[i].pList; @@ -57,8 +58,7 @@ int CIcqProto::StringToListItemId(const char *szSetting,int def) int ChangeInfoData::UploadSettings(void) { - if (!ppro->icqOnline()) - { + if (!ppro->icqOnline()) { MessageBox(hwndDlg, TranslateT("You are not currently connected to the ICQ network. You must be online in order to update your information on the server."), TranslateT("Change ICQ Details"), MB_OK); return 0; } @@ -67,10 +67,8 @@ int ChangeInfoData::UploadSettings(void) //password char* tmp = ppro->GetUserPassword(TRUE); - if (tmp) - { - if (strlennull(Password) > 0 && strcmpnull(Password, tmp)) - { + if (tmp) { + if (strlennull(Password) > 0 && strcmpnull(Password, tmp)) { // update password in user info dialog (still open) strcpy(Password, tmp); // update password in protocol @@ -79,16 +77,9 @@ int ChangeInfoData::UploadSettings(void) hUpload[1] = (HANDLE)ppro->icq_changeUserPasswordServ(tmp); char szPwd[PASSWORDMAXLEN] = {0}; + // password is stored in DB, update if (ppro->GetUserStoredPassword(szPwd, sizeof(szPwd))) - { // password is stored in DB, update - char ptmp[PASSWORDMAXLEN]; - - strcpy(ptmp, tmp); - - CallService(MS_DB_CRYPT_ENCODESTRING, sizeof(ptmp), (LPARAM)ptmp); - - ppro->setString("Password", ptmp); - } + ppro->setString("Password", tmp); } } diff --git a/protocols/IcqOscarJ/src/icq_firstrun.cpp b/protocols/IcqOscarJ/src/icq_firstrun.cpp index 9a5d6bbe11..47dd485da1 100644 --- a/protocols/IcqOscarJ/src/icq_firstrun.cpp +++ b/protocols/IcqOscarJ/src/icq_firstrun.cpp @@ -29,13 +29,11 @@ // ----------------------------------------------------------------------------- #include "icqoscar.h" - static void accountLoadDetails(CIcqProto *ppro, HWND hwndDlg) { char pszUIN[20]; DWORD dwUIN = ppro->getContactUin(NULL); - if (dwUIN) - { + if (dwUIN) { mir_snprintf(pszUIN, 20, "%u", dwUIN); SetDlgItemTextA(hwndDlg, IDC_UIN, pszUIN); } @@ -45,7 +43,6 @@ static void accountLoadDetails(CIcqProto *ppro, HWND hwndDlg) SetDlgItemTextA(hwndDlg, IDC_PW, pszPwd); } - INT_PTR CALLBACK icq_FirstRunDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { CIcqProto* ppro = (CIcqProto*)GetWindowLongPtr( hwndDlg, GWLP_USERDATA ); @@ -75,48 +72,42 @@ INT_PTR CALLBACK icq_FirstRunDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR break; case WM_COMMAND: - switch (LOWORD(wParam)) - { + switch (LOWORD(wParam)) { case IDC_REGISTER: CallService(MS_UTILS_OPENURL, 1, (LPARAM)URL_REGISTER); break; - case IDC_UIN: - case IDC_PW: - if (HIWORD(wParam) == EN_CHANGE && (HWND)lParam == GetFocus()) - { - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + case IDC_UIN: + case IDC_PW: + if (HIWORD(wParam) == EN_CHANGE && (HWND)lParam == GetFocus()) { + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; } - } - break; + } + break; case WM_NOTIFY: - switch (((LPNMHDR)lParam)->code) - { + switch (((LPNMHDR)lParam)->code) { case PSN_APPLY: - { - char str[128]; - GetDlgItemTextA(hwndDlg, IDC_UIN, str, sizeof(str)); - ppro->setDword(UNIQUEIDSETTING, atoi(str)); - GetDlgItemTextA(hwndDlg, IDC_PW, str, sizeof(ppro->m_szPassword)); - strcpy(ppro->m_szPassword, str); - CallService(MS_DB_CRYPT_ENCODESTRING, sizeof(ppro->m_szPassword), (LPARAM) str); - ppro->setString("Password", str); - } - break; - - case PSN_RESET: - accountLoadDetails(ppro, hwndDlg); - break; - } + char str[128]; + GetDlgItemTextA(hwndDlg, IDC_UIN, str, sizeof(str)); + ppro->setDword(UNIQUEIDSETTING, atoi(str)); + + GetDlgItemTextA(hwndDlg, IDC_PW, str, sizeof(ppro->m_szPassword)); + strcpy(ppro->m_szPassword, str); + ppro->setString("Password", str); + break; + + case PSN_RESET: + accountLoadDetails(ppro, hwndDlg); + break; + } break; } return FALSE; } - INT_PTR CIcqProto::OnCreateAccMgrUI(WPARAM wParam, LPARAM lParam) { return (INT_PTR)CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ICQACCOUNT), (HWND)lParam, icq_FirstRunDlgProc, LPARAM(this)); diff --git a/protocols/IcqOscarJ/src/icq_opts.cpp b/protocols/IcqOscarJ/src/icq_opts.cpp index f8c3e3c2a9..ded5f25990 100644 --- a/protocols/IcqOscarJ/src/icq_opts.cpp +++ b/protocols/IcqOscarJ/src/icq_opts.cpp @@ -78,12 +78,10 @@ static INT_PTR CALLBACK DlgProcIcqOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP SendDlgItemMessage(hwndDlg, IDC_PASSWORD, EM_LIMITTEXT, PASSWORDMAXLEN - 1, 0); + // bit of a security hole here, since it's easy to extract a password from an edit box char pszPwd[PASSWORDMAXLEN]; if (ppro->GetUserStoredPassword(pszPwd, sizeof(pszPwd))) - { - //bit of a security hole here, since it's easy to extract a password from an edit box SetDlgItemTextA(hwndDlg, IDC_PASSWORD, pszPwd); - } LoadDBCheckState(ppro, hwndDlg, IDC_SSL, "SecureConnection", DEFAULT_SECURE_CONNECTION); LoadDBCheckState(ppro, hwndDlg, IDC_MD5LOGIN, "SecureLogin", DEFAULT_SECURE_LOGIN); @@ -106,86 +104,73 @@ static INT_PTR CALLBACK DlgProcIcqOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP return TRUE; case WM_HSCROLL: - { - SetDlgItemText(hwndDlg, IDC_LEVELDESCR, TranslateTS(szLogLevelDescr[4-SendDlgItemMessage(hwndDlg, IDC_LOGLEVEL,TBM_GETPOS, 0, 0)])); - OptDlgChanged(hwndDlg); - } + SetDlgItemText(hwndDlg, IDC_LEVELDESCR, TranslateTS(szLogLevelDescr[4-SendDlgItemMessage(hwndDlg, IDC_LOGLEVEL,TBM_GETPOS, 0, 0)])); + OptDlgChanged(hwndDlg); break; case WM_COMMAND: - { - switch (LOWORD(wParam)) { - case IDC_LOOKUPLINK: - CallService(MS_UTILS_OPENURL, 1, (LPARAM)URL_FORGOT_PASSWORD); - return TRUE; - - case IDC_NEWUINLINK: - CallService(MS_UTILS_OPENURL, 1, (LPARAM)URL_REGISTER); - return TRUE; - - case IDC_RESETSERVER: - SetDlgItemInt(hwndDlg, IDC_ICQPORT, IsDlgButtonChecked(hwndDlg, IDC_SSL) ? DEFAULT_SERVER_PORT_SSL : DEFAULT_SERVER_PORT, FALSE); + switch (LOWORD(wParam)) { + case IDC_LOOKUPLINK: + CallService(MS_UTILS_OPENURL, 1, (LPARAM)URL_FORGOT_PASSWORD); + return TRUE; - case IDC_SSL: - SetDlgItemTextA(hwndDlg, IDC_ICQSERVER, IsDlgButtonChecked(hwndDlg, IDC_SSL) ? DEFAULT_SERVER_HOST_SSL : DEFAULT_SERVER_HOST); - SetDlgItemInt(hwndDlg, IDC_ICQPORT, IsDlgButtonChecked(hwndDlg, IDC_SSL) ? DEFAULT_SERVER_PORT_SSL : DEFAULT_SERVER_PORT, FALSE); - OptDlgChanged(hwndDlg); - return TRUE; - } + case IDC_NEWUINLINK: + CallService(MS_UTILS_OPENURL, 1, (LPARAM)URL_REGISTER); + return TRUE; - if (ppro->icqOnline() && LOWORD(wParam) != IDC_NOERRMULTI) - { - char szClass[80]; - GetClassNameA((HWND)lParam, szClass, sizeof(szClass)); + case IDC_RESETSERVER: + SetDlgItemInt(hwndDlg, IDC_ICQPORT, IsDlgButtonChecked(hwndDlg, IDC_SSL) ? DEFAULT_SERVER_PORT_SSL : DEFAULT_SERVER_PORT, FALSE); - if (stricmpnull(szClass, "EDIT") || HIWORD(wParam) == EN_CHANGE) - ShowDlgItem(hwndDlg, IDC_RECONNECTREQD, SW_SHOW); - } + case IDC_SSL: + SetDlgItemTextA(hwndDlg, IDC_ICQSERVER, IsDlgButtonChecked(hwndDlg, IDC_SSL) ? DEFAULT_SERVER_HOST_SSL : DEFAULT_SERVER_HOST); + SetDlgItemInt(hwndDlg, IDC_ICQPORT, IsDlgButtonChecked(hwndDlg, IDC_SSL) ? DEFAULT_SERVER_PORT_SSL : DEFAULT_SERVER_PORT, FALSE); + OptDlgChanged(hwndDlg); + return TRUE; + } - if ((LOWORD(wParam)==IDC_ICQNUM || LOWORD(wParam)==IDC_PASSWORD || LOWORD(wParam)==IDC_ICQSERVER || LOWORD(wParam)==IDC_ICQPORT) && - (HIWORD(wParam)!=EN_CHANGE || (HWND)lParam!=GetFocus())) - { - return 0; - } + if (ppro->icqOnline() && LOWORD(wParam) != IDC_NOERRMULTI) { + char szClass[80]; + GetClassNameA((HWND)lParam, szClass, sizeof(szClass)); - OptDlgChanged(hwndDlg); - break; + if (stricmpnull(szClass, "EDIT") || HIWORD(wParam) == EN_CHANGE) + ShowDlgItem(hwndDlg, IDC_RECONNECTREQD, SW_SHOW); } - case WM_NOTIFY: + if ((LOWORD(wParam)==IDC_ICQNUM || LOWORD(wParam)==IDC_PASSWORD || LOWORD(wParam)==IDC_ICQSERVER || LOWORD(wParam)==IDC_ICQPORT) && + (HIWORD(wParam)!=EN_CHANGE || (HWND)lParam!=GetFocus())) { - switch (((LPNMHDR)lParam)->code) - { + return 0; + } - case PSN_APPLY: - { - char str[128]; + OptDlgChanged(hwndDlg); + break; - ppro->setDword(UNIQUEIDSETTING, GetDlgItemInt(hwndDlg, IDC_ICQNUM, NULL, FALSE)); - GetDlgItemTextA(hwndDlg, IDC_PASSWORD, str, sizeof(ppro->m_szPassword)); - if (strlennull(str)) - { - strcpy(ppro->m_szPassword, str); - ppro->m_bRememberPwd = TRUE; - } - else - ppro->m_bRememberPwd = ppro->getByte("RememberPass", 0); - - CallService(MS_DB_CRYPT_ENCODESTRING, sizeof(ppro->m_szPassword), (LPARAM)str); - ppro->setString("Password", str); - GetDlgItemTextA(hwndDlg,IDC_ICQSERVER, str, sizeof(str)); - ppro->setString("OscarServer", str); - ppro->setWord("OscarPort", (WORD)GetDlgItemInt(hwndDlg, IDC_ICQPORT, NULL, FALSE)); - StoreDBCheckState(ppro, hwndDlg, IDC_KEEPALIVE, "KeepAlive"); - StoreDBCheckState(ppro, hwndDlg, IDC_SSL, "SecureConnection"); - StoreDBCheckState(ppro, hwndDlg, IDC_MD5LOGIN, "SecureLogin"); - StoreDBCheckState(ppro, hwndDlg, IDC_LEGACY, "LegacyFix"); - StoreDBCheckState(ppro, hwndDlg, IDC_NOERRMULTI, "IgnoreMultiErrorBox"); - ppro->setByte("ShowLogLevel", (BYTE)(4-SendDlgItemMessage(hwndDlg, IDC_LOGLEVEL, TBM_GETPOS, 0, 0))); - - return TRUE; - } + case WM_NOTIFY: + switch (((LPNMHDR)lParam)->code) { + case PSN_APPLY: + char str[128]; + + ppro->setDword(UNIQUEIDSETTING, GetDlgItemInt(hwndDlg, IDC_ICQNUM, NULL, FALSE)); + GetDlgItemTextA(hwndDlg, IDC_PASSWORD, str, sizeof(ppro->m_szPassword)); + if (strlennull(str)) { + strcpy(ppro->m_szPassword, str); + ppro->m_bRememberPwd = TRUE; } + else ppro->m_bRememberPwd = ppro->getByte("RememberPass", 0); + ppro->setString("Password", str); + + GetDlgItemTextA(hwndDlg,IDC_ICQSERVER, str, sizeof(str)); + ppro->setString("OscarServer", str); + + ppro->setWord("OscarPort", (WORD)GetDlgItemInt(hwndDlg, IDC_ICQPORT, NULL, FALSE)); + + StoreDBCheckState(ppro, hwndDlg, IDC_KEEPALIVE, "KeepAlive"); + StoreDBCheckState(ppro, hwndDlg, IDC_SSL, "SecureConnection"); + StoreDBCheckState(ppro, hwndDlg, IDC_MD5LOGIN, "SecureLogin"); + StoreDBCheckState(ppro, hwndDlg, IDC_LEGACY, "LegacyFix"); + StoreDBCheckState(ppro, hwndDlg, IDC_NOERRMULTI, "IgnoreMultiErrorBox"); + ppro->setByte("ShowLogLevel", (BYTE)(4-SendDlgItemMessage(hwndDlg, IDC_LOGLEVEL, TBM_GETPOS, 0, 0))); + return TRUE; } break; } diff --git a/protocols/IcqOscarJ/src/utilities.cpp b/protocols/IcqOscarJ/src/utilities.cpp index 1e073e55b0..de9d020fd6 100644 --- a/protocols/IcqOscarJ/src/utilities.cpp +++ b/protocols/IcqOscarJ/src/utilities.cpp @@ -1791,12 +1791,9 @@ char* __fastcall ICQTranslateUtfStatic(const char *src, char *buf, size_t bufsiz char* CIcqProto::GetUserStoredPassword(char *szBuffer, int cbSize) { if (!getSettingStringStatic(NULL, "Password", szBuffer, cbSize)) - { - CallService(MS_DB_CRYPT_DECODESTRING, strlennull(szBuffer) + 1, (LPARAM)szBuffer); - if (strlennull(szBuffer)) return szBuffer; - } + return NULL; } -- cgit v1.2.3