From 6b325192ae0a7764c231f1c5b7a4cee3f240f0a7 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 29 May 2015 22:03:39 +0000 Subject: even less mir_strncat() git-svn-id: http://svn.miranda-ng.org/main/trunk@13903 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/HTTPServer/src/IndexHTML.cpp | 6 ++---- plugins/HTTPServer/src/IndexXML.cpp | 14 ++++++-------- protocols/Gadu-Gadu/src/filetransfer.cpp | 8 +++----- 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/plugins/HTTPServer/src/IndexHTML.cpp b/plugins/HTTPServer/src/IndexHTML.cpp index a2ae11602f..fb554acd65 100644 --- a/plugins/HTTPServer/src/IndexHTML.cpp +++ b/plugins/HTTPServer/src/IndexHTML.cpp @@ -62,8 +62,7 @@ bool LoadIndexHTMLTemplate() { char szDestBuf[10000]; char* pszDestBuf = szDestBuf; - strncpy(pszBuf, szPluginPath, SIZEOF(szBuf)-1); - mir_strncat(pszBuf, szIndexHTMLTemplateFile, SIZEOF(szBuf) - mir_strlen(szBuf)); + mir_snprintf(szBuf, _countof(szBuf), "%s%s", szPluginPath, szIndexHTMLTemplateFile); HANDLE hFile = CreateFile(pszBuf, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); @@ -283,8 +282,7 @@ bool bCreateIndexHTML(const char * pszRealPath, const char * pszIndexPath, // check if directory exists char szMask[MAX_PATH]; - strncpy(szMask, pszRealPath, MAX_PATH- 1); - mir_strncat(szMask, "*", SIZEOF(szMask) - mir_strlen(szMask)); + mir_snprintf(szMask, _countof(szMask), "%s%s", pszRealPath, "*"); WIN32_FIND_DATAA fdFindFileData; HANDLE hFind = FindFirstFile(szMask, &fdFindFileData); diff --git a/plugins/HTTPServer/src/IndexXML.cpp b/plugins/HTTPServer/src/IndexXML.cpp index 7de9c2cc8b..a1006d5a69 100644 --- a/plugins/HTTPServer/src/IndexXML.cpp +++ b/plugins/HTTPServer/src/IndexXML.cpp @@ -61,15 +61,13 @@ static void ReplaceSign(char* pszSrc, int MaxLength, const char pszReplace, // Developer : Houdini ///////////////////////////////////////////////////////////////////// -bool bCreateIndexXML(const char * pszRealPath, const char * pszIndexPath, - const char * pszSrvPath, DWORD dwRemoteIP) { +bool bCreateIndexXML(const char * pszRealPath, const char * pszIndexPath, const char * pszSrvPath, DWORD dwRemoteIP) +{ char szMask[MAX_PATH+1]; - strncpy(szMask, pszRealPath, MAX_PATH); - mir_strncat(szMask, "*", SIZEOF(szMask) - mir_strlen(szMask)); + mir_snprintf(szMask, _countof(szMask), "%s%s", pszRealPath, "*"); WIN32_FIND_DATAA fdFindFileData; HANDLE hFind = FindFirstFile(szMask, &fdFindFileData); - if (hFind == INVALID_HANDLE_VALUE) return FALSE; @@ -102,8 +100,7 @@ bool bCreateIndexXML(const char * pszRealPath, const char * pszIndexPath, WriteFile(hFile, szXmlHeader1, sizeof(szXmlHeader1) - 1, &dwBytesWritten, NULL); // check if a index.xsl exists in the same directory otherwise use the global - strncpy(szMask, pszRealPath, MAX_PATH); - mir_strncat(szMask, "index.xsl", SIZEOF(szMask) - mir_strlen(szMask)); + mir_snprintf(szMask, _countof(szMask), "%s%s", pszRealPath, "index.xsl"); HANDLE hFileExists = CreateFile(szMask, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, @@ -111,7 +108,8 @@ bool bCreateIndexXML(const char * pszRealPath, const char * pszIndexPath, if (hFileExists == INVALID_HANDLE_VALUE) { strncpy(szBuffer, "/index.xsl", BUFFER_SIZE); - } else { + } + else { CloseHandle(hFileExists); strncpy(szBuffer, "index.xsl", BUFFER_SIZE); } diff --git a/protocols/Gadu-Gadu/src/filetransfer.cpp b/protocols/Gadu-Gadu/src/filetransfer.cpp index 53e3668e3c..3190ac35bb 100644 --- a/protocols/Gadu-Gadu/src/filetransfer.cpp +++ b/protocols/Gadu-Gadu/src/filetransfer.cpp @@ -702,16 +702,14 @@ HANDLE GGPROTO::dcc7fileallow(HANDLE hTransfer, const PROTOCHAR* szPath) { struct gg_dcc7 *dcc7 = (struct gg_dcc7 *) hTransfer; char fileName[MAX_PATH], *path = mir_t2a(szPath); - int iFtRemoveRes; - strncpy(fileName, path, sizeof(fileName)); - mir_strncat(fileName, (char*)dcc7->filename, sizeof(fileName) - mir_strlen(fileName)); - dcc7->folder = _strdup((char *) path); + mir_snprintf(fileName, _countof(fileName), "%s%s", path, dcc7->filename); + dcc7->folder = _strdup((char*)path); dcc7->tick = 0; mir_free(path); // Remove transfer from waiting list gg_EnterCriticalSection(&ft_mutex, "dcc7fileallow", 40, "ft_mutex", 1); - iFtRemoveRes = list_remove(&transfers, dcc7, 0); + int iFtRemoveRes = list_remove(&transfers, dcc7, 0); gg_LeaveCriticalSection(&ft_mutex, "dcc7fileallow", 40, 1, "ft_mutex", 1); if (iFtRemoveRes == -1) -- cgit v1.2.3