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/Utils/mir_buffer.h | 2 +- plugins/Utils/mir_fonts.cpp | 18 +++++++++--------- plugins/Utils/mir_options.cpp | 14 +++++++------- 3 files changed, 17 insertions(+), 17 deletions(-) (limited to 'plugins/Utils') diff --git a/plugins/Utils/mir_buffer.h b/plugins/Utils/mir_buffer.h index 4aa0a2602e..ac7c909860 100644 --- a/plugins/Utils/mir_buffer.h +++ b/plugins/Utils/mir_buffer.h @@ -468,7 +468,7 @@ static void ReplaceVars(Buffer *buffer, MCONTACT hContact, TCHAR **variab else if (foundLen == 6 && _tcsncmp(&buffer->str[j], _T("%date%"), 6) == 0) { TCHAR tmp[128]; - TimeZone_ToStringT(time(NULL), _T("d s"), tmp, SIZEOF(tmp)); + TimeZone_ToStringT(time(NULL), _T("d s"), tmp, _countof(tmp)); buffer->replace(j, i + 1, tmp); } else diff --git a/plugins/Utils/mir_fonts.cpp b/plugins/Utils/mir_fonts.cpp index d18dfd020c..d617e87b59 100644 --- a/plugins/Utils/mir_fonts.cpp +++ b/plugins/Utils/mir_fonts.cpp @@ -12,10 +12,10 @@ int FontService_RegisterFont(const char *pszDbModule, const char *pszDbName, con fid.cbSize = sizeof(fid); mir_strncpy(fid.dbSettingsGroup, pszDbModule, sizeof(fid.dbSettingsGroup)); /* buffer safe */ mir_strncpy(fid.prefix, pszDbName, sizeof(fid.prefix)); /* buffer safe */ - mir_tstrncpy(fid.group, pszSection, SIZEOF(fid.group)); /* buffer safe */ - mir_tstrncpy(fid.name, pszDescription, SIZEOF(fid.name)); /* buffer safe */ - mir_tstrncpy(fid.backgroundGroup, pszBackgroundGroup, SIZEOF(fid.backgroundGroup)); /* buffer safe */ - mir_tstrncpy(fid.backgroundName, pszBackgroundName, SIZEOF(fid.backgroundName)); /* buffer safe */ + mir_tstrncpy(fid.group, pszSection, _countof(fid.group)); /* buffer safe */ + mir_tstrncpy(fid.name, pszDescription, _countof(fid.name)); /* buffer safe */ + mir_tstrncpy(fid.backgroundGroup, pszBackgroundGroup, _countof(fid.backgroundGroup)); /* buffer safe */ + mir_tstrncpy(fid.backgroundName, pszBackgroundName, _countof(fid.backgroundName)); /* buffer safe */ fid.flags = FIDF_ALLOWREREGISTER; if (bAllowEffects) fid.flags |= FIDF_ALLOWEFFECTS; fid.order = position; @@ -28,7 +28,7 @@ int FontService_RegisterFont(const char *pszDbModule, const char *pszDbName, con if (plfDefault->lfUnderline) fid.deffontsettings.style |= DBFONTF_UNDERLINE; if (plfDefault->lfStrikeOut) fid.deffontsettings.style |= DBFONTF_STRIKEOUT; fid.deffontsettings.charset = plfDefault->lfCharSet; - mir_tstrncpy(fid.deffontsettings.szFace, plfDefault->lfFaceName, SIZEOF(fid.deffontsettings.szFace)); /* buffer safe */ + mir_tstrncpy(fid.deffontsettings.szFace, plfDefault->lfFaceName, _countof(fid.deffontsettings.szFace)); /* buffer safe */ } FontRegisterT(&fid); return 0; @@ -37,8 +37,8 @@ int FontService_RegisterFont(const char *pszDbModule, const char *pszDbName, con int FontService_GetFont(const TCHAR *pszSection, const TCHAR *pszDescription, COLORREF *pclr, LOGFONT *plf) { FontIDT fid = { 0 }; - mir_tstrncpy(fid.group, pszSection, SIZEOF(fid.group)); /* buffer sfae */ - mir_tstrncpy(fid.name, pszDescription, SIZEOF(fid.name)); /* buffer safe */ + mir_tstrncpy(fid.group, pszSection, _countof(fid.group)); /* buffer sfae */ + mir_tstrncpy(fid.name, pszDescription, _countof(fid.name)); /* buffer safe */ *pclr = (COLORREF)CallService(MS_FONT_GETT, (WPARAM)&fid, (LPARAM)plf); /* uses fallback font on error */ return (int)*pclr == -1; } @@ -50,8 +50,8 @@ int FontService_RegisterColor(const char *pszDbModule, const char *pszDbName, co cid.defcolour = clrDefault; mir_strncpy(cid.dbSettingsGroup, pszDbModule, sizeof(cid.dbSettingsGroup)); /* buffer safe */ mir_strncpy(cid.setting, pszDbName, sizeof(cid.setting)); /* buffer safe */ - mir_tstrncpy(cid.group, pszSection, SIZEOF(cid.group)); /* buffer safe */ - mir_tstrncpy(cid.name, pszDescription, SIZEOF(cid.name)); /* buffer safe */ + mir_tstrncpy(cid.group, pszSection, _countof(cid.group)); /* buffer safe */ + mir_tstrncpy(cid.name, pszDescription, _countof(cid.name)); /* buffer safe */ ColourRegisterT(&cid); return 0; } diff --git a/plugins/Utils/mir_options.cpp b/plugins/Utils/mir_options.cpp index 9618b51c4f..b65b7645e6 100644 --- a/plugins/Utils/mir_options.cpp +++ b/plugins/Utils/mir_options.cpp @@ -70,8 +70,8 @@ static void PathToRelative(TCHAR *pOut, size_t outSize, const TCHAR *pSrc) else { if (dbPath[0] == _T('\0')) { char tmp[1024]; - CallService(MS_DB_GETPROFILEPATH, SIZEOF(tmp), (LPARAM)tmp); - mir_sntprintf(dbPath, SIZEOF(dbPath), _T("%S\\"), tmp); + CallService(MS_DB_GETPROFILEPATH, _countof(tmp), (LPARAM)tmp); + mir_sntprintf(dbPath, _countof(dbPath), _T("%S\\"), tmp); } size_t len = mir_tstrlen(dbPath); @@ -88,8 +88,8 @@ static void PathToAbsolute(TCHAR *pOut, size_t outSize, const TCHAR *pSrc) else { if (dbPath[0] == _T('\0')) { char tmp[1024]; - CallService(MS_DB_GETPROFILEPATH, SIZEOF(tmp), (LPARAM)tmp); - mir_sntprintf(dbPath, SIZEOF(dbPath), _T("%S\\"), tmp); + CallService(MS_DB_GETPROFILEPATH, _countof(tmp), (LPARAM)tmp); + mir_sntprintf(dbPath, _countof(dbPath), _T("%S\\"), tmp); } mir_sntprintf(pOut, outSize, _T("%s%s"), dbPath, pSrc); @@ -360,7 +360,7 @@ INT_PTR CALLBACK SaveOptsDlgProc(OptPageControl *controls, int controlsSize, cha case CONTROL_TEXT: { TCHAR tmp[1024]; - GetDlgItemText(hwndDlg, ctrl->nID, tmp, SIZEOF(tmp)); + GetDlgItemText(hwndDlg, ctrl->nID, tmp, _countof(tmp)); db_set_ts(NULL, module, ctrl->setting, tmp); } break; @@ -381,7 +381,7 @@ INT_PTR CALLBACK SaveOptsDlgProc(OptPageControl *controls, int controlsSize, cha case CONTROL_FILE: { TCHAR tmp[1024]; - GetDlgItemText(hwndDlg, ctrl->nID, tmp, SIZEOF(tmp)); + GetDlgItemText(hwndDlg, ctrl->nID, tmp, _countof(tmp)); TCHAR rel[1024]; PathToRelative(rel, 1024, tmp); db_set_ts(NULL, module, ctrl->setting, rel); @@ -390,7 +390,7 @@ INT_PTR CALLBACK SaveOptsDlgProc(OptPageControl *controls, int controlsSize, cha case CONTROL_COMBO_TEXT: { TCHAR tmp[1024]; - GetDlgItemText(hwndDlg, ctrl->nID, tmp, SIZEOF(tmp)); + GetDlgItemText(hwndDlg, ctrl->nID, tmp, _countof(tmp)); db_set_ts(NULL, module, ctrl->setting, tmp); } break; -- cgit v1.2.3