From 4c814798c7bc7f6a0f92c21b027b26290622aa2f Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 19 Jun 2015 19:35:42 +0000 Subject: SIZEOF replaced with more secure analog - _countof git-svn-id: http://svn.miranda-ng.org/main/trunk@14270 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/SeenPlugin/src/history.cpp | 2 +- plugins/SeenPlugin/src/missed.cpp | 4 ++-- plugins/SeenPlugin/src/options.cpp | 20 ++++++++++---------- plugins/SeenPlugin/src/utils.cpp | 30 +++++++++++++++--------------- 4 files changed, 28 insertions(+), 28 deletions(-) (limited to 'plugins/SeenPlugin/src') diff --git a/plugins/SeenPlugin/src/history.cpp b/plugins/SeenPlugin/src/history.cpp index 6698122920..857719e78f 100644 --- a/plugins/SeenPlugin/src/history.cpp +++ b/plugins/SeenPlugin/src/history.cpp @@ -174,7 +174,7 @@ INT_PTR CALLBACK HistoryDlgProc(HWND hwndDlg, UINT Message, WPARAM wparam, LPARA TranslateDialogDefault(hwndDlg); hContact = (MCONTACT)lparam; SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lparam); - mir_sntprintf(sztemp, SIZEOF(sztemp), _T("%s: %s"), + mir_sntprintf(sztemp, _countof(sztemp), _T("%s: %s"), CallService(MS_CLIST_GETCONTACTDISPLAYNAME, hContact, GCDNF_TCHAR), TranslateT("last seen history")); SetWindowText(hwndDlg, sztemp); diff --git a/plugins/SeenPlugin/src/missed.cpp b/plugins/SeenPlugin/src/missed.cpp index f975ff4f39..3ff3d8751c 100644 --- a/plugins/SeenPlugin/src/missed.cpp +++ b/plugins/SeenPlugin/src/missed.cpp @@ -107,9 +107,9 @@ int ShowMissed(void) TCHAR sztemp[1024], szcount[7]; for (int loop = 0; loop < mcs.count; loop++) { - mir_tstrncat(sztemp, (TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, mcs.wpcontact[loop], GCDNF_TCHAR), SIZEOF(sztemp) - mir_tstrlen(sztemp)); + mir_tstrncat(sztemp, (TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, mcs.wpcontact[loop], GCDNF_TCHAR), _countof(sztemp) - mir_tstrlen(sztemp)); if (db_get_b(NULL, S_MOD, "MissedOnes_Count", 0)) { - mir_sntprintf(szcount, SIZEOF(szcount), _T(" [%i]"), mcs.times[loop]); + mir_sntprintf(szcount, _countof(szcount), _T(" [%i]"), mcs.times[loop]); mir_tstrcat(sztemp, szcount); } diff --git a/plugins/SeenPlugin/src/options.cpp b/plugins/SeenPlugin/src/options.cpp index e51c8dad93..8bb34912f8 100644 --- a/plugins/SeenPlugin/src/options.cpp +++ b/plugins/SeenPlugin/src/options.cpp @@ -92,10 +92,10 @@ INT_PTR CALLBACK OptsPopupsDlgProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lp SendDlgItemMessage(hdlg, idText, CPM_SETCOLOUR, 0, ppd.colorText); ppd.lchIcon = Skin_LoadProtoIcon(NULL, idBack); - GetDlgItemText(hdlg, IDC_POPUPSTAMP, szstamp, SIZEOF(szstamp)); + GetDlgItemText(hdlg, IDC_POPUPSTAMP, szstamp, _countof(szstamp)); _tcsncpy(ppd.lptzContactName, ParseString(szstamp, NULL, 0), MAX_CONTACTNAME); - GetDlgItemText(hdlg, IDC_POPUPSTAMPTEXT, szstamp, SIZEOF(szstamp)); + GetDlgItemText(hdlg, IDC_POPUPSTAMPTEXT, szstamp, _countof(szstamp)); _tcsncpy(ppd.lptzText, ParseString(szstamp, NULL, 0), MAX_SECONDLINE); PUAddPopupT(&ppd); @@ -131,10 +131,10 @@ INT_PTR CALLBACK OptsPopupsDlgProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lp case 0: switch (((LPNMHDR)lparam)->code) { case PSN_APPLY: - GetDlgItemText(hdlg, IDC_POPUPSTAMP, szstamp, SIZEOF(szstamp)); + GetDlgItemText(hdlg, IDC_POPUPSTAMP, szstamp, _countof(szstamp)); db_set_ts(NULL, S_MOD, "PopupStamp", szstamp); - GetDlgItemText(hdlg, IDC_POPUPSTAMPTEXT, szstamp, SIZEOF(szstamp)); + GetDlgItemText(hdlg, IDC_POPUPSTAMPTEXT, szstamp, _countof(szstamp)); db_set_ts(NULL, S_MOD, "PopupStampText", szstamp); bchecked = (BYTE)IsDlgButtonChecked(hdlg, IDC_POPUPS); @@ -278,7 +278,7 @@ INT_PTR CALLBACK OptsSettingsDlgProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM if (LOWORD(wparam) == IDC_VARIABLES) { char szout[2048]; - mir_snprintf(szout, SIZEOF(szout), VARIABLE_LIST); + mir_snprintf(szout, _countof(szout), VARIABLE_LIST); MessageBoxA(hdlg, szout, Translate("Last Seen Variables"), MB_OK | MB_TOPMOST); } break; //case WM_COMMAND @@ -288,19 +288,19 @@ INT_PTR CALLBACK OptsSettingsDlgProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM case 0: switch (((LPNMHDR)lparam)->code) { case PSN_APPLY: - GetDlgItemText(hdlg, IDC_MENUSTAMP, szstamp, SIZEOF(szstamp)); + GetDlgItemText(hdlg, IDC_MENUSTAMP, szstamp, _countof(szstamp)); db_set_ts(NULL, S_MOD, "MenuStamp", szstamp); - GetDlgItemText(hdlg, IDC_USERSTAMP, szstamp, SIZEOF(szstamp)); + GetDlgItemText(hdlg, IDC_USERSTAMP, szstamp, _countof(szstamp)); db_set_ts(NULL, S_MOD, "UserStamp", szstamp); - GetDlgItemText(hdlg, IDC_FILESTAMP, szstamp, SIZEOF(szstamp)); + GetDlgItemText(hdlg, IDC_FILESTAMP, szstamp, _countof(szstamp)); db_set_ts(NULL, S_MOD, "FileStamp", szstamp); - GetDlgItemText(hdlg, IDC_FILENAME, szstamp, SIZEOF(szstamp)); + GetDlgItemText(hdlg, IDC_FILENAME, szstamp, _countof(szstamp)); db_set_ts(NULL, S_MOD, "FileName", szstamp); - GetDlgItemText(hdlg, IDC_HISTORYSTAMP, szstamp, SIZEOF(szstamp)); + GetDlgItemText(hdlg, IDC_HISTORYSTAMP, szstamp, _countof(szstamp)); db_set_ts(NULL, S_MOD, "HistoryStamp", szstamp); db_set_w(NULL, S_MOD, "HistoryMax", (WORD)(GetDlgItemInt(hdlg, IDC_HISTORYSIZE, NULL, FALSE) + 1)); diff --git a/plugins/SeenPlugin/src/utils.cpp b/plugins/SeenPlugin/src/utils.cpp index 6a1818d295..65a3d1f613 100644 --- a/plugins/SeenPlugin/src/utils.cpp +++ b/plugins/SeenPlugin/src/utils.cpp @@ -266,7 +266,7 @@ TCHAR *ParseString(TCHAR *szstring, MCONTACT hcontact, BYTE isfile) case 'G': if (!db_get_ts(hcontact, "CList", "Group", &dbv)) { - _tcsncpy(szdbsetting, dbv.ptszVal, SIZEOF(szdbsetting)); + _tcsncpy(szdbsetting, dbv.ptszVal, _countof(szdbsetting)); db_free(&dbv); charPtr = szdbsetting; goto LBL_charPtr; @@ -287,7 +287,7 @@ TCHAR *ParseString(TCHAR *szstring, MCONTACT hcontact, BYTE isfile) _ltot(ci.dVal, szdbsetting, 10); break; case CNFT_ASCIIZ: - _tcsncpy(szdbsetting, ci.pszVal, SIZEOF(szdbsetting)); + _tcsncpy(szdbsetting, ci.pszVal, _countof(szdbsetting)); break; } } @@ -297,10 +297,10 @@ TCHAR *ParseString(TCHAR *szstring, MCONTACT hcontact, BYTE isfile) case 's': if (isetting = db_get_w(hcontact, S_MOD, hcontact ? "StatusTriger" : courProtoName, 0)) { - _tcsncpy(szdbsetting, (TCHAR*)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, (WPARAM)(isetting | 0x8000), GSMDF_TCHAR), SIZEOF(szdbsetting)); + _tcsncpy(szdbsetting, (TCHAR*)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, (WPARAM)(isetting | 0x8000), GSMDF_TCHAR), _countof(szdbsetting)); if (!(isetting & 0x8000)) { - mir_tstrncat(szdbsetting, _T("/"), SIZEOF(szdbsetting) - mir_tstrlen(szdbsetting)); - mir_tstrncat(szdbsetting, TranslateT("Idle"), SIZEOF(szdbsetting) - mir_tstrlen(szdbsetting)); + mir_tstrncat(szdbsetting, _T("/"), _countof(szdbsetting) - mir_tstrlen(szdbsetting)); + mir_tstrncat(szdbsetting, TranslateT("Idle"), _countof(szdbsetting) - mir_tstrlen(szdbsetting)); } charPtr = szdbsetting; goto LBL_charPtr; @@ -317,10 +317,10 @@ TCHAR *ParseString(TCHAR *szstring, MCONTACT hcontact, BYTE isfile) case 'o': if (isetting = db_get_w(hcontact, S_MOD, hcontact ? "OldStatus" : courProtoName, 0)) { - _tcsncpy(szdbsetting, (TCHAR*)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, (WPARAM)isetting, GSMDF_TCHAR), SIZEOF(szdbsetting)); + _tcsncpy(szdbsetting, (TCHAR*)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, (WPARAM)isetting, GSMDF_TCHAR), _countof(szdbsetting)); if (includeIdle && hcontact && db_get_b(hcontact, S_MOD, "OldIdle", 0)) { - mir_tstrncat(szdbsetting, _T("/"), SIZEOF(szdbsetting) - mir_tstrlen(szdbsetting)); - mir_tstrncat(szdbsetting, TranslateT("Idle"), SIZEOF(szdbsetting) - mir_tstrlen(szdbsetting)); + mir_tstrncat(szdbsetting, _T("/"), _countof(szdbsetting) - mir_tstrlen(szdbsetting)); + mir_tstrncat(szdbsetting, TranslateT("Idle"), _countof(szdbsetting) - mir_tstrlen(szdbsetting)); } charPtr = szdbsetting; goto LBL_charPtr; @@ -333,7 +333,7 @@ TCHAR *ParseString(TCHAR *szstring, MCONTACT hcontact, BYTE isfile) if (db_get_ts(hcontact, ci.szProto, *p == 'i' ? "Resource" : "System", &dbv)) goto LBL_noData; - _tcsncpy(szdbsetting, dbv.ptszVal, SIZEOF(szdbsetting)); + _tcsncpy(szdbsetting, dbv.ptszVal, _countof(szdbsetting)); db_free(&dbv); charPtr = szdbsetting; } @@ -343,13 +343,13 @@ TCHAR *ParseString(TCHAR *szstring, MCONTACT hcontact, BYTE isfile) goto LBL_noData; ia.S_un.S_addr = htonl(dwsetting); - _tcsncpy(szdbsetting, _A2T(inet_ntoa(ia)), SIZEOF(szdbsetting)); + _tcsncpy(szdbsetting, _A2T(inet_ntoa(ia)), _countof(szdbsetting)); charPtr = szdbsetting; } goto LBL_charPtr; case 'P': - _tcsncpy(szdbsetting, ci.szProto ? _A2T(ci.szProto) : (wantempty ? _T("") : _T("ProtoUnknown")), SIZEOF(szdbsetting)); + _tcsncpy(szdbsetting, ci.szProto ? _A2T(ci.szProto) : (wantempty ? _T("") : _T("ProtoUnknown")), _countof(szdbsetting)); charPtr = szdbsetting; goto LBL_charPtr; @@ -359,7 +359,7 @@ TCHAR *ParseString(TCHAR *szstring, MCONTACT hcontact, BYTE isfile) case 'C': // Get Client Info if (!db_get_ts(hcontact, ci.szProto, "MirVer", &dbv)) { - _tcsncpy(szdbsetting, dbv.ptszVal, SIZEOF(szdbsetting)); + _tcsncpy(szdbsetting, dbv.ptszVal, _countof(szdbsetting)); db_free(&dbv); } else goto LBL_noData; @@ -374,7 +374,7 @@ TCHAR *ParseString(TCHAR *szstring, MCONTACT hcontact, BYTE isfile) { PROTOACCOUNT *pa = Proto_GetAccount(ci.szProto); if (!pa) goto LBL_noData; - _tcsncpy(szdbsetting, pa->tszAccountName, SIZEOF(szdbsetting)); + _tcsncpy(szdbsetting, pa->tszAccountName, _countof(szdbsetting)); charPtr = szdbsetting; goto LBL_charPtr; } @@ -642,7 +642,7 @@ int UpdateValues(WPARAM hContact, LPARAM lparam) if (p == NULL) { p = (logthread_info*)mir_calloc(sizeof(logthread_info)); p->hContact = hContact; - mir_strncpy(p->sProtoName, cws->szModule, SIZEOF(p->sProtoName)); + mir_strncpy(p->sProtoName, cws->szModule, _countof(p->sProtoName)); arContacts.insert(p); mir_forkthread(waitThread, p); } @@ -697,7 +697,7 @@ int ModeChange(WPARAM wparam, LPARAM lparam) db_set_dw(NULL, "UserOnline", ack->szModule, GetTickCount()); if (!Miranda_Terminated() && IsWatchedProtocol(ack->szModule)) { logthread_info *info = (logthread_info *)mir_alloc(sizeof(logthread_info)); - mir_strncpy(info->sProtoName, courProtoName, SIZEOF(info->sProtoName)); + mir_strncpy(info->sProtoName, courProtoName, _countof(info->sProtoName)); info->hContact = 0; info->currStatus = 0; -- cgit v1.2.3