summaryrefslogtreecommitdiff
path: root/src/modules/chat
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2015-04-11 15:20:17 +0000
committerGeorge Hazan <george.hazan@gmail.com>2015-04-11 15:20:17 +0000
commit7e315d1103af9248583483da99e96ca339bf2d20 (patch)
tree6398336a2286278e6857e3205247ba0ed74a2e20 /src/modules/chat
parentc391c203e82d635e58561911ac7753c1d1261cc9 (diff)
unsafe string operations replaced with safe wherever possible
git-svn-id: http://svn.miranda-ng.org/main/trunk@12768 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/modules/chat')
-rw-r--r--src/modules/chat/chat_opts.cpp2
-rw-r--r--src/modules/chat/chat_rtf.cpp15
-rw-r--r--src/modules/chat/log.cpp2
-rw-r--r--src/modules/chat/tools.cpp2
4 files changed, 8 insertions, 13 deletions
diff --git a/src/modules/chat/chat_opts.cpp b/src/modules/chat/chat_opts.cpp
index 872bf4a033..5a2497b21a 100644
--- a/src/modules/chat/chat_opts.cpp
+++ b/src/modules/chat/chat_opts.cpp
@@ -171,7 +171,7 @@ void RegisterFonts(void)
_tcsncpy_s(fontid.backgroundName, LPGENT("Group chat log background"), _TRUNCATE);
break;
}
- _tcsncpy(fontid.deffontsettings.szFace, FO.szDefFace, SIZEOF(fontid.deffontsettings.szFace));
+ _tcsncpy_s(fontid.deffontsettings.szFace, FO.szDefFace, _TRUNCATE);
fontid.deffontsettings.charset = FO.defCharset;
fontid.deffontsettings.colour = FO.defColour;
fontid.deffontsettings.size = FO.defSize;
diff --git a/src/modules/chat/chat_rtf.cpp b/src/modules/chat/chat_rtf.cpp
index 2cff984c84..8373a833d5 100644
--- a/src/modules/chat/chat_rtf.cpp
+++ b/src/modules/chat/chat_rtf.cpp
@@ -167,16 +167,11 @@ int DoRtfToTags(CMString &pszText, int iNumColors, COLORREF *pColors)
}
else if (p[1] == '\'') { // special character
if (p[2] != ' ' && p[2] != '\\') {
- TCHAR tmp[10];
-
- if (p[3] != ' ' && p[3] != '\\') {
- _tcsncpy(tmp, p + 2, 3);
- tmp[3] = 0;
- }
- else {
- _tcsncpy(tmp, p + 2, 2);
- tmp[2] = 0;
- }
+ TCHAR tmp[10], *t = tmp;
+ *t++ = p[2];
+ if (p[3] != ' ' && p[3] != '\\')
+ *t++ = p[3];
+ *t = 0;
// convert string containing char in hex format to int.
TCHAR *stoppedHere;
diff --git a/src/modules/chat/log.cpp b/src/modules/chat/log.cpp
index 44b0ac9248..9be458b09d 100644
--- a/src/modules/chat/log.cpp
+++ b/src/modules/chat/log.cpp
@@ -316,7 +316,7 @@ TCHAR* MakeTimeStamp(TCHAR *pszStamp, time_t time)
{
static TCHAR szTime[30];
if (!_tcsftime(szTime, SIZEOF(szTime)-1, pszStamp, localtime(&time)))
- _tcsncpy(szTime, TranslateT("<invalid>"), SIZEOF(szTime));
+ _tcsncpy_s(szTime, TranslateT("<invalid>"), _TRUNCATE);
return szTime;
}
diff --git a/src/modules/chat/tools.cpp b/src/modules/chat/tools.cpp
index 6f06421591..061555ccc4 100644
--- a/src/modules/chat/tools.cpp
+++ b/src/modules/chat/tools.cpp
@@ -463,7 +463,7 @@ BOOL LogToFile(SESSION_INFO *si, GCEVENT *gce)
BOOL bFileJustCreated = !PathFileExists(si->pszLogFileName);
TCHAR tszFolder[MAX_PATH];
- _tcscpy(tszFolder, si->pszLogFileName);
+ _tcsncpy_s(tszFolder, si->pszLogFileName, _TRUNCATE);
PathRemoveFileSpec(tszFolder);
if (!PathIsDirectory(tszFolder))
CreateDirectoryTreeT(tszFolder);