diff options
author | George Hazan <george.hazan@gmail.com> | 2015-06-19 19:35:42 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-06-19 19:35:42 +0000 |
commit | 4c814798c7bc7f6a0f92c21b027b26290622aa2f (patch) | |
tree | 9bbfb38bd639f352300aa16ff7c45f5a9b2dba6d /plugins/SecureIM | |
parent | f0f0cd088f1ec3a85abee825ddbc214f3f6b92c3 (diff) |
SIZEOF replaced with more secure analog - _countof
git-svn-id: http://svn.miranda-ng.org/main/trunk@14270 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/SecureIM')
-rw-r--r-- | plugins/SecureIM/src/crypt_lists.cpp | 2 | ||||
-rw-r--r-- | plugins/SecureIM/src/loadicons.cpp | 6 | ||||
-rw-r--r-- | plugins/SecureIM/src/main.cpp | 2 | ||||
-rw-r--r-- | plugins/SecureIM/src/options.cpp | 32 | ||||
-rw-r--r-- | plugins/SecureIM/src/popupOptions.cpp | 6 | ||||
-rw-r--r-- | plugins/SecureIM/src/svcs_clist.cpp | 4 |
6 files changed, 26 insertions, 26 deletions
diff --git a/plugins/SecureIM/src/crypt_lists.cpp b/plugins/SecureIM/src/crypt_lists.cpp index 8d1fcc1fd0..25e004f09d 100644 --- a/plugins/SecureIM/src/crypt_lists.cpp +++ b/plugins/SecureIM/src/crypt_lists.cpp @@ -30,7 +30,7 @@ void loadSupportedProtocols() SupPro *p = (SupPro*)mir_calloc(sizeof(SupPro));
p->name = mir_strdup(protos[i]->szModuleName);
if (szNames && p->name) {
- char tmp[128]; strncpy(tmp, p->name, sizeof(tmp) - 1); mir_strncat(tmp, ":", SIZEOF(tmp) - mir_strlen(tmp));
+ char tmp[128]; strncpy(tmp, p->name, sizeof(tmp) - 1); mir_strncat(tmp, ":", _countof(tmp) - mir_strlen(tmp));
LPSTR szName = strstr(szNames, tmp);
if (szName) {
szName = strchr(szName, ':');
diff --git a/plugins/SecureIM/src/loadicons.cpp b/plugins/SecureIM/src/loadicons.cpp index bac49973cf..d13a3a746e 100644 --- a/plugins/SecureIM/src/loadicons.cpp +++ b/plugins/SecureIM/src/loadicons.cpp @@ -58,7 +58,7 @@ HINSTANCE LoadIconsPack(const char* szIconsPack) int ReloadIcons(WPARAM wParam, LPARAM lParam)
{
- for (int i = 0; i < SIZEOF(icons); i++) {
+ for (int i = 0; i < _countof(icons); i++) {
HICON hIcon = IcoLib_GetIcon(icons[i].name);
if (icons[i].tbl == TBL_IEC)
g_hIEC[icons[i].idx] = hIcon;
@@ -94,13 +94,13 @@ void InitIcons(void) g_hIconInst = hNewIconInst;
TCHAR tszPath[MAX_PATH];
- GetModuleFileName(g_hIconInst, tszPath, SIZEOF(tszPath));
+ GetModuleFileName(g_hIconInst, tszPath, _countof(tszPath));
SKINICONDESC sid = { 0 };
sid.section.a = "SecureIM";
sid.defaultFile.t = tszPath;
- for (int i = 0; i < SIZEOF(icons); i++) {
+ for (int i = 0; i < _countof(icons); i++) {
sid.section.a = icons[i].section;
sid.pszName = icons[i].name;
sid.description.a = icons[i].text;
diff --git a/plugins/SecureIM/src/main.cpp b/plugins/SecureIM/src/main.cpp index ab5c5de63f..dc6dbbf80b 100644 --- a/plugins/SecureIM/src/main.cpp +++ b/plugins/SecureIM/src/main.cpp @@ -212,7 +212,7 @@ static int onModulesLoaded(WPARAM, LPARAM) SkinAddNewSound("OutgoingSecureMessage", LPGEN("Outgoing Secure Message"), "Sounds\\oSecureMessage.wav");
// init extra icons
- for (int i = 0; i < SIZEOF(g_IEC); i++)
+ for (int i = 0; i < _countof(g_IEC); i++)
g_IEC[i] = (HANDLE)-1;
HookEvent(ME_CLIST_PREBUILDCONTACTMENU, onRebuildContactMenu);
diff --git a/plugins/SecureIM/src/options.cpp b/plugins/SecureIM/src/options.cpp index a3e2b75b60..60beb05651 100644 --- a/plugins/SecureIM/src/options.cpp +++ b/plugins/SecureIM/src/options.cpp @@ -518,7 +518,7 @@ INT_PTR CALLBACK DlgProcOptionsProto(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM switch (LOWORD(wParam)) {
case IDC_RSA_COPY:
char txt[128];
- GetDlgItemText(hDlg, IDC_RSA_SHA, txt, SIZEOF(txt));
+ GetDlgItemText(hDlg, IDC_RSA_SHA, txt, _countof(txt));
CopyToClipboard(hDlg, txt);
return TRUE;
@@ -803,17 +803,17 @@ INT_PTR CALLBACK DlgProcOptionsGPG(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM l {
char gpgexe[256];
char filter[128];
- GetDlgItemText(hDlg, IDC_GPGEXECUTABLE_EDIT, gpgexe, SIZEOF(gpgexe));
+ GetDlgItemText(hDlg, IDC_GPGEXECUTABLE_EDIT, gpgexe, _countof(gpgexe));
// filter zusammensetzen
- mir_snprintf(filter, SIZEOF(filter), _T("%s (*.exe)%c*.exe%c%c"), Translate("Executable Files"), 0, 0, 0);
+ mir_snprintf(filter, _countof(filter), _T("%s (*.exe)%c*.exe%c%c"), Translate("Executable Files"), 0, 0, 0);
// OPENFILENAME initialisieren
OPENFILENAME ofn = { sizeof(ofn) };
ofn.hwndOwner = hDlg;
ofn.lpstrFilter = filter;
ofn.lpstrFile = gpgexe;
- ofn.nMaxFile = SIZEOF(gpgexe);
+ ofn.nMaxFile = _countof(gpgexe);
ofn.lpstrTitle = Translate("Select GnuPG Executable");
ofn.Flags = OFN_FILEMUSTEXIST | OFN_LONGNAMES | OFN_HIDEREADONLY;
@@ -1042,7 +1042,7 @@ void RefreshPGPDlg(HWND hDlg, BOOL iInit) if (bPGPloaded && ver) {
char pgpVerStr[64];
- mir_snprintf(pgpVerStr, SIZEOF(pgpVerStr), Translate(sim218), ver >> 24, (ver >> 16) & 255, (ver >> 8) & 255);
+ mir_snprintf(pgpVerStr, _countof(pgpVerStr), Translate(sim218), ver >> 24, (ver >> 16) & 255, (ver >> 8) & 255);
SetDlgItemText(hDlg, IDC_PGP_SDK, pgpVerStr);
}
else SetDlgItemText(hDlg, IDC_PGP_SDK, Translate(sim219));
@@ -1327,9 +1327,9 @@ void ApplyGPGSettings(HWND hDlg) {
char tmp[256];
- GetDlgItemText(hDlg, IDC_GPGEXECUTABLE_EDIT, tmp, SIZEOF(tmp));
+ GetDlgItemText(hDlg, IDC_GPGEXECUTABLE_EDIT, tmp, _countof(tmp));
db_set_s(0, MODULENAME, "gpgExec", tmp);
- GetDlgItemText(hDlg, IDC_GPGHOME_EDIT, tmp, SIZEOF(tmp));
+ GetDlgItemText(hDlg, IDC_GPGHOME_EDIT, tmp, _countof(tmp));
db_set_s(0, MODULENAME, "gpgHome", tmp);
bSavePass = (IsDlgButtonChecked(hDlg, IDC_SAVEPASS_CBOX) == BST_CHECKED);
@@ -1337,14 +1337,14 @@ void ApplyGPGSettings(HWND hDlg) BOOL bgpgLogFlag = (IsDlgButtonChecked(hDlg, IDC_LOGGINGON_CBOX) == BST_CHECKED);
db_set_b(0, MODULENAME, "gpgLogFlag", bgpgLogFlag);
- GetDlgItemText(hDlg, IDC_GPGLOGFILE_EDIT, tmp, SIZEOF(tmp));
+ GetDlgItemText(hDlg, IDC_GPGLOGFILE_EDIT, tmp, _countof(tmp));
db_set_s(0, MODULENAME, "gpgLog", tmp);
if (bgpgLogFlag) gpg_set_log(tmp);
else gpg_set_log(0);
BOOL bgpgTmpFlag = (IsDlgButtonChecked(hDlg, IDC_TMPPATHON_CBOX) == BST_CHECKED);
db_set_b(0, MODULENAME, "gpgTmpFlag", bgpgTmpFlag);
- GetDlgItemText(hDlg, IDC_GPGTMPPATH_EDIT, tmp, SIZEOF(tmp));
+ GetDlgItemText(hDlg, IDC_GPGTMPPATH_EDIT, tmp, _countof(tmp));
db_set_s(0, MODULENAME, "gpgTmp", tmp);
if (bgpgTmpFlag) gpg_set_tmp(tmp);
else gpg_set_tmp(0);
@@ -1414,7 +1414,7 @@ void setListViewStatus(HWND hLV, UINT iItem, UINT iStatus) UINT getListViewPSK(HWND hLV, UINT iItem)
{
char str[128];
- LV_GetItemTextA(hLV, iItem, 4, str, SIZEOF(str));
+ LV_GetItemTextA(hLV, iItem, 4, str, _countof(str));
return strncmp(str, Translate(sim206), sizeof(str)) == 0;
}
@@ -1428,7 +1428,7 @@ void setListViewPSK(HWND hLV, UINT iItem, UINT iStatus) UINT getListViewPUB(HWND hLV, UINT iItem)
{
char str[128];
- LV_GetItemTextA(hLV, iItem, 4, str, SIZEOF(str));
+ LV_GetItemTextA(hLV, iItem, 4, str, _countof(str));
return strncmp(str, Translate(sim233), sizeof(str)) == 0;
}
@@ -1548,14 +1548,14 @@ void ListView_Sort(HWND hLV, LPARAM lParamSort) {
// restore sort column
char t[32];
- mir_snprintf(t, SIZEOF(t), "os%02x", (UINT)lParamSort & 0xF0);
+ mir_snprintf(t, _countof(t), "os%02x", (UINT)lParamSort & 0xF0);
if ((lParamSort & 0x0F) == 0)
lParamSort = (int)db_get_b(0, MODULENAME, t, lParamSort + 1);
db_set_b(0, MODULENAME, t, (BYTE)lParamSort);
// restore sort order
- mir_snprintf(t, SIZEOF(t), "os%02x", (UINT)lParamSort);
+ mir_snprintf(t, _countof(t), "os%02x", (UINT)lParamSort);
int m = db_get_b(0, MODULENAME, t, 0);
if (bChangeSortOrder) { m = !m; db_set_b(0, MODULENAME, t, m); }
@@ -1571,7 +1571,7 @@ BOOL ShowSelectKeyDlg(HWND hParent, LPSTR KeyPath) ofn.lpstrFile = KeyPath;
char temp[MAX_PATH];
- mir_snprintf(temp, SIZEOF(temp), _T("%s (*.asc)%c*.asc%c%s (*.*)%c*.*%c%c"), Translate("ASC files"), 0, 0, Translate("All files"), 0, 0, 0);
+ mir_snprintf(temp, _countof(temp), _T("%s (*.asc)%c*.asc%c%s (*.*)%c*.*%c%c"), Translate("ASC files"), 0, 0, Translate("All files"), 0, 0, 0);
ofn.lpstrFilter = temp;
ofn.lpstrTitle = TranslateT("Open Key File");
if (!GetOpenFileName(&ofn)) return FALSE;
@@ -1628,7 +1628,7 @@ BOOL SaveExportRSAKeyDlg(HWND hParent, LPSTR key, BOOL priv) OPENFILENAME ofn = { sizeof(ofn) };
char temp[MAX_PATH];
- mir_snprintf(temp, SIZEOF(temp), _T("%s (*.asc)%c*.asc%c%s (*.*)%c*.*%c%c"), Translate("ASC files"), 0, 0, Translate("All files"), 0, 0, 0);
+ mir_snprintf(temp, _countof(temp), _T("%s (*.asc)%c*.asc%c%s (*.*)%c*.*%c%c"), Translate("ASC files"), 0, 0, Translate("All files"), 0, 0, 0);
ofn.lpstrFilter = temp;
ofn.hwndOwner = hParent;
ofn.nMaxFile = MAX_PATH;
@@ -1661,7 +1661,7 @@ BOOL LoadImportRSAKeyDlg(HWND hParent, LPSTR key, BOOL priv) ofn.Flags = OFN_EXPLORER | OFN_CREATEPROMPT | OFN_OVERWRITEPROMPT | OFN_NOREADONLYRETURN;
ofn.lpstrFile = szFile;
char temp[MAX_PATH];
- mir_snprintf(temp, SIZEOF(temp), _T("%s (*.asc)%c*.asc%c%s (*.*)%c*.*%c%c"), Translate("ASC files"), 0, 0, Translate("All files"), 0, 0, 0);
+ mir_snprintf(temp, _countof(temp), _T("%s (*.asc)%c*.asc%c%s (*.*)%c*.*%c%c"), Translate("ASC files"), 0, 0, Translate("All files"), 0, 0, 0);
ofn.lpstrFilter = temp;
ofn.lpstrTitle = (priv) ? TranslateT("Load Private Key File") : TranslateT("Load Public Key File");
if (!GetOpenFileName(&ofn))
diff --git a/plugins/SecureIM/src/popupOptions.cpp b/plugins/SecureIM/src/popupOptions.cpp index 393659d271..88f3235436 100644 --- a/plugins/SecureIM/src/popupOptions.cpp +++ b/plugins/SecureIM/src/popupOptions.cpp @@ -111,19 +111,19 @@ INT_PTR CALLBACK PopOptionsDlgProc(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM l break;
case IDC_TIMEKEY:
//set timeout value
- GetDlgItemText(hDlg, IDC_TIMEKEY, getTimeout, SIZEOF(getTimeout));
+ GetDlgItemText(hDlg, IDC_TIMEKEY, getTimeout, _countof(getTimeout));
mir_itoa(atoi(getTimeout), getTimeout, 10);
db_set_s(0, MODULENAME, "timeoutKey", getTimeout);
break;
case IDC_TIMESEC:
//set timeout value
- GetDlgItemText(hDlg, IDC_TIMESEC, getTimeout, SIZEOF(getTimeout));
+ GetDlgItemText(hDlg, IDC_TIMESEC, getTimeout, _countof(getTimeout));
mir_itoa(atoi(getTimeout), getTimeout, 10);
db_set_s(0, MODULENAME, "timeoutSec", getTimeout);
break;
case IDC_TIMESR:
//set timeout value
- GetDlgItemText(hDlg, IDC_TIMESR, getTimeout, SIZEOF(getTimeout));
+ GetDlgItemText(hDlg, IDC_TIMESR, getTimeout, _countof(getTimeout));
mir_itoa(atoi(getTimeout), getTimeout, 10);
db_set_s(0, MODULENAME, "timeoutSR", getTimeout);
break;
diff --git a/plugins/SecureIM/src/svcs_clist.cpp b/plugins/SecureIM/src/svcs_clist.cpp index 0d5dd38d57..59a5f30230 100644 --- a/plugins/SecureIM/src/svcs_clist.cpp +++ b/plugins/SecureIM/src/svcs_clist.cpp @@ -77,7 +77,7 @@ int __cdecl onRebuildContactMenu(WPARAM hContact, LPARAM lParam) // check offline/online
if (!ptr) {
// hide menu bars
- for (i = 0; i < SIZEOF(g_hMenu); i++)
+ for (i = 0; i < _countof(g_hMenu); i++)
Menu_ShowItem(g_hMenu[i], false);
return 0;
}
@@ -90,7 +90,7 @@ int __cdecl onRebuildContactMenu(WPARAM hContact, LPARAM lParam) bool isMiranda = isClientMiranda(hContact);
// hide all menu bars
- for (i = 0; i < SIZEOF(g_hMenu); i++)
+ for (i = 0; i < _countof(g_hMenu); i++)
Menu_ShowItem(g_hMenu[i], false);
if (isSecureProto && !isChat && isMiranda &&
|