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/HTTPServer/src/GuiElements.cpp | 18 +++++++++--------- plugins/HTTPServer/src/HttpUser.cpp | 10 +++++----- plugins/HTTPServer/src/IndexHTML.cpp | 4 ++-- plugins/HTTPServer/src/IndexXML.cpp | 2 +- plugins/HTTPServer/src/main.cpp | 4 ++-- 5 files changed, 19 insertions(+), 19 deletions(-) (limited to 'plugins/HTTPServer/src') diff --git a/plugins/HTTPServer/src/GuiElements.cpp b/plugins/HTTPServer/src/GuiElements.cpp index cf1157ad3b..b76183bcf3 100644 --- a/plugins/HTTPServer/src/GuiElements.cpp +++ b/plugins/HTTPServer/src/GuiElements.cpp @@ -284,7 +284,7 @@ UINT_PTR CALLBACK ShareNewFileDialogHook( HWND hFileName = GetDlgItem(hWndFileDlg, edt1); char pszFileName[MAX_PATH]; - GetWindowText(hFileName, pszFileName, SIZEOF(pszFileName)); + GetWindowText(hFileName, pszFileName, _countof(pszFileName)); if (mir_strcmp(pstShare->pszSrvPath, szSelection) && mir_strcmp(pszFileName, pszShareDirStr)) { @@ -435,7 +435,7 @@ bool bShowShareNewFileDlg(HWND hwndOwner, STFileShareInfo * pstNewShare) { ofn.lStructSize = sizeof(OPENFILENAME); char temp[MAX_PATH]; - mir_snprintf(temp, SIZEOF(temp), _T("%s (*.*)%c*.*%c%c"), Translate("All files"), 0, 0, 0); + mir_snprintf(temp, _countof(temp), _T("%s (*.*)%c*.*%c%c"), Translate("All files"), 0, 0, 0); ofn.lpstrFilter = temp; ofn.lpstrFile = pstNewShare->pszRealPath; @@ -854,7 +854,7 @@ static INT_PTR CALLBACK DlgProcStatsticView(HWND hwndDlg, UINT msg, WPARAM wPara LVITEM sItem = { 0 }; sItem.mask = LVIF_TEXT; sItem.pszText = szTmp; - sItem.cchTextMax = SIZEOF(szTmp); + sItem.cchTextMax = _countof(szTmp); switch (LOWORD(wParam)) { case IDC_SHOWHIDDENSHARES: { @@ -1212,11 +1212,11 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP case IDC_TEST_EXTERNALIP: { char szUrl[ 500 ]; char szKeyWord[ 1000 ]; - GetDlgItemText(hwndDlg, IDC_URL_ADDRESS, szUrl, SIZEOF(szUrl)); - GetDlgItemText(hwndDlg, IDC_PAGE_KEYWORD, szKeyWord, SIZEOF(szKeyWord)); + GetDlgItemText(hwndDlg, IDC_URL_ADDRESS, szUrl, _countof(szUrl)); + GetDlgItemText(hwndDlg, IDC_PAGE_KEYWORD, szKeyWord, _countof(szKeyWord)); DWORD dwExternalIP = GetExternIP(szUrl, szKeyWord); - mir_snprintf(szKeyWord, SIZEOF(szKeyWord), Translate("Your external IP was detected as %d.%d.%d.%d\r\nby: %s") , + mir_snprintf(szKeyWord, _countof(szKeyWord), Translate("Your external IP was detected as %d.%d.%d.%d\r\nby: %s") , SplitIpAddress(dwExternalIP) , szUrl); MessageBox(hwndDlg, szKeyWord, MSG_BOX_TITEL, MB_OK); @@ -1229,7 +1229,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP switch (p->code) { case PSN_APPLY: { char szTemp[ 500 ]; - if (GetDlgItemText(hwndDlg, IDC_EXTERNAL_SRV_NAME, szTemp, SIZEOF(szTemp))) + if (GetDlgItemText(hwndDlg, IDC_EXTERNAL_SRV_NAME, szTemp, _countof(szTemp))) db_set_s(NULL, MODULE, "ExternalSrvName", szTemp); bool b = db_get_b(NULL, MODULE, "AddStatisticsMenuItem", 1) != 0; @@ -1252,11 +1252,11 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP bShowPopups = IsDlgButtonChecked(hwndDlg, IDC_SHOW_POPUPS) == BST_CHECKED; db_set_b(NULL, MODULE, "ShowPopups", bShowPopups); - GetDlgItemText(hwndDlg, IDC_URL_ADDRESS, szTemp, SIZEOF(szTemp)); + GetDlgItemText(hwndDlg, IDC_URL_ADDRESS, szTemp, _countof(szTemp)); sUrlAddress = szTemp; db_set_s(NULL, MODULE, "UrlAddress", sUrlAddress.c_str()); - GetDlgItemText(hwndDlg, IDC_PAGE_KEYWORD, szTemp, SIZEOF(szTemp)); + GetDlgItemText(hwndDlg, IDC_PAGE_KEYWORD, szTemp, _countof(szTemp)); sPageKeyword = szTemp; db_set_s(NULL, MODULE, "PageKeyword", sPageKeyword.c_str()); dwExternalIpAddress = 0; diff --git a/plugins/HTTPServer/src/HttpUser.cpp b/plugins/HTTPServer/src/HttpUser.cpp index e1398215bc..a4e2597fd7 100644 --- a/plugins/HTTPServer/src/HttpUser.cpp +++ b/plugins/HTTPServer/src/HttpUser.cpp @@ -231,7 +231,7 @@ void CLHttpUser::SendError(int iErrorCode, const char * pszError, const char * p pszDescription = pszError; char szBuf[1000]; - DWORD dwBytesToWrite = mir_snprintf(szBuf, SIZEOF(szBuf), + DWORD dwBytesToWrite = mir_snprintf(szBuf, _countof(szBuf), "HTTP/1.1 %i %s\r\n" "Date: %s\r\n" "Server: MirandaWeb/%s\r\n" @@ -281,7 +281,7 @@ void CLHttpUser::SendRedir(int iErrorCode, const char * pszError, const char * p pszDescription = pszError; char szBuff[1000]; - DWORD dwBytesToWrite = mir_snprintf(szBuff, SIZEOF(szBuff), + DWORD dwBytesToWrite = mir_snprintf(szBuff, _countof(szBuff), "HTTP/1.1 %i %s\r\n" "Date: %s\r\n" "Server: MirandaWeb/%s\r\n" @@ -546,7 +546,7 @@ bool CLHttpUser::bProcessGetRequest(char * pszRequest, bool bIsGetCommand) { char szETag[ 50 ]; { - int nETagLen = mir_snprintf(szETag, SIZEOF(szETag), "\"%x-%x-%x\"", + int nETagLen = mir_snprintf(szETag, _countof(szETag), "\"%x-%x-%x\"", nDataSize, stFileTime.dwHighDateTime, stFileTime.dwLowDateTime); if (!apszParam[eIfRange] || (strncmp(szETag, apszParam[eIfRange], nETagLen) == 0)) { @@ -616,7 +616,7 @@ bool CLHttpUser::bProcessGetRequest(char * pszRequest, bool bIsGetCommand) { "Last-Modified: %s\r\n" "\r\n"; - dwBytesToWrite = mir_snprintf(szBuf, SIZEOF(szBuf), szHttpPartial, + dwBytesToWrite = mir_snprintf(szBuf, _countof(szBuf), szHttpPartial, szCurTime, PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM), szETag, @@ -638,7 +638,7 @@ bool CLHttpUser::bProcessGetRequest(char * pszRequest, bool bIsGetCommand) { "Last-Modified: %s\r\n" "\r\n"; - dwBytesToWrite = mir_snprintf(szBuf, SIZEOF(szBuf), szHttpOk, + dwBytesToWrite = mir_snprintf(szBuf, _countof(szBuf), szHttpOk, szCurTime, PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM), szETag, diff --git a/plugins/HTTPServer/src/IndexHTML.cpp b/plugins/HTTPServer/src/IndexHTML.cpp index 6170657766..04a991cb4e 100644 --- a/plugins/HTTPServer/src/IndexHTML.cpp +++ b/plugins/HTTPServer/src/IndexHTML.cpp @@ -317,14 +317,14 @@ bool bCreateIndexHTML(const char * pszRealPath, const char * pszIndexPath, bool bEvenOdd = 0; bool bKnownFileType = false; - strncpy(szBuffer, pszSrvPath, SIZEOF(szBuffer)-1); + strncpy(szBuffer, pszSrvPath, _countof(szBuffer)-1); char* pszTemp = strrchr(szBuffer, '/'); if (pszTemp) *pszTemp = '\0'; pszTemp = strrchr(szBuffer, '/'); if (pszTemp) - strncpy(szName, pszTemp + 1, SIZEOF(szName)-1); + strncpy(szName, pszTemp + 1, _countof(szName)-1); if (szName[0] == '\0') mir_strcpy(szName, "my Miranda Webserver"); diff --git a/plugins/HTTPServer/src/IndexXML.cpp b/plugins/HTTPServer/src/IndexXML.cpp index 6a4e232798..b6b79bab1d 100644 --- a/plugins/HTTPServer/src/IndexXML.cpp +++ b/plugins/HTTPServer/src/IndexXML.cpp @@ -32,7 +32,7 @@ static void ReplaceSign(char* pszSrc, int MaxLength, const char pszReplace, char* pszSign = strchr(pszSrc, pszReplace); if (pszSign) { - strncpy(szBuffer, pszSrc, SIZEOF(szBuffer)-1); + strncpy(szBuffer, pszSrc, _countof(szBuffer)-1); do { mir_strcpy(szBuffer + (pszSign - pszSrc), pszNew); diff --git a/plugins/HTTPServer/src/main.cpp b/plugins/HTTPServer/src/main.cpp index 24ff38bc1e..1629bfcf18 100644 --- a/plugins/HTTPServer/src/main.cpp +++ b/plugins/HTTPServer/src/main.cpp @@ -347,7 +347,7 @@ bool bWriteConfigurationFile() { } else { CLFileShareNode * pclCur = pclFirstNode; while (pclCur) { - DWORD dwBytesToWrite = mir_snprintf(szBuf, SIZEOF(szBuf), szXmlData , + DWORD dwBytesToWrite = mir_snprintf(szBuf, _countof(szBuf), szXmlData , pclCur->st.pszSrvPath, pclCur->pszOrigRealPath, pclCur->st.nMaxDownloads, @@ -900,7 +900,7 @@ int nSystemShutdown(WPARAM /*wparam*/, LPARAM /*lparam*/) { MessageBox(NULL, _T("Failed to retrieve plugin path."), MSG_BOX_TITEL, MB_OK); return 1; } - mir_tstrncat(szPluginPath, _T("\\HTTPServer\\"), SIZEOF(szPluginPath) - mir_tstrlen(szPluginPath)); + mir_tstrncat(szPluginPath, _T("\\HTTPServer\\"), _countof(szPluginPath) - mir_tstrlen(szPluginPath)); int err = CreateDirectoryTree(szPluginPath); if((err != 0) && (err != ERROR_ALREADY_EXISTS)) { -- cgit v1.2.3