summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/AdvaImg/src/main.cpp8
-rw-r--r--plugins/Alarms/src/alarms.cpp8
-rw-r--r--plugins/BossKeyPlus/src/BossKey.cpp10
-rw-r--r--plugins/ChangeKeyboardLayout/src/hook_events.cpp2
-rw-r--r--plugins/Clist_modern/src/modern_cachefuncs.cpp4
-rw-r--r--plugins/Clist_modern/src/modern_clc.cpp2
-rw-r--r--plugins/Clist_modern/src/modern_rowtemplateopt.cpp6
-rw-r--r--plugins/Clist_nicer/src/CLUIFrames/cluiframes.cpp2
-rw-r--r--plugins/Clist_nicer/src/clcutils.cpp56
-rw-r--r--plugins/ConnectionNotify/src/ConnectionNotify.cpp10
-rw-r--r--plugins/CrashDumper/src/crshdmp.cpp2
-rw-r--r--plugins/ExternalAPI/m_folders.h4
-rw-r--r--plugins/FingerprintNG/src/fingerprint.cpp4
-rw-r--r--plugins/Folders/src/utils.cpp4
-rw-r--r--plugins/IEView/src/TemplateHTMLBuilder.cpp4
-rw-r--r--plugins/IEView/src/ieview_services.cpp2
-rw-r--r--plugins/KeyboardNotify/src/main.cpp12
-rw-r--r--plugins/NewAwaySysMod/src/Services.cpp2
-rwxr-xr-xplugins/New_GPG/src/main.cpp21
-rw-r--r--plugins/NotesAndReminders/src/reminders.cpp2
-rw-r--r--plugins/Scriver/src/infobar.cpp4
-rw-r--r--plugins/Scriver/src/msgoptions.cpp6
-rw-r--r--plugins/Scriver/src/msgtimedout.cpp2
-rw-r--r--plugins/SimpleStatusMsg/src/awaymsg.cpp2
-rw-r--r--plugins/Spamotron/src/popups.cpp12
-rw-r--r--plugins/TabSRMM/src/chat/log.cpp2
-rw-r--r--plugins/TabSRMM/src/chat/main.cpp2
-rw-r--r--plugins/TabSRMM/src/chat/options.cpp8
-rw-r--r--plugins/TabSRMM/src/contactcache.cpp6
-rw-r--r--plugins/TabSRMM/src/container.cpp2
-rw-r--r--plugins/TabSRMM/src/containeroptions.cpp2
-rw-r--r--plugins/TabSRMM/src/controls.cpp2
-rw-r--r--plugins/TabSRMM/src/eventpopups.cpp4
-rw-r--r--plugins/TabSRMM/src/generic_msghandlers.cpp6
-rw-r--r--plugins/TabSRMM/src/infopanel.cpp5
-rw-r--r--plugins/TabSRMM/src/mim.cpp14
-rw-r--r--plugins/TabSRMM/src/msgdlgutils.cpp43
-rw-r--r--plugins/TabSRMM/src/msgoptions.cpp4
-rw-r--r--plugins/TabSRMM/src/sendlater.cpp4
-rw-r--r--plugins/TabSRMM/src/sendqueue.cpp2
-rw-r--r--plugins/TabSRMM/src/sidebar.cpp2
-rw-r--r--plugins/TabSRMM/src/templates.cpp2
-rw-r--r--plugins/TabSRMM/src/themeio.cpp10
-rw-r--r--plugins/TabSRMM/src/themes.cpp2
-rw-r--r--plugins/TabSRMM/src/trayicon.cpp10
-rw-r--r--plugins/TabSRMM/src/utils.cpp4
-rw-r--r--plugins/Utils/mir_options.cpp7
-rw-r--r--plugins/Weather/src/weather_conv.cpp8
-rw-r--r--plugins/YAMN/src/browser/mailbrowser.cpp8
-rw-r--r--protocols/AimOscar/src/popup.cpp2
-rw-r--r--protocols/FacebookRM/src/proto.cpp2
-rw-r--r--protocols/Gadu-Gadu/src/image.cpp2
-rw-r--r--protocols/IRCG/src/options.cpp4
-rw-r--r--protocols/JabberG/src/jabber_chat.cpp10
-rw-r--r--protocols/JabberG/src/jabber_disco.cpp2
-rw-r--r--protocols/JabberG/src/jabber_rc.cpp4
-rw-r--r--protocols/JabberG/src/jabber_svc.cpp2
-rw-r--r--protocols/JabberG/src/jabber_userinfo.cpp6
-rw-r--r--protocols/MRA/src/Mra_functions.cpp2
-rw-r--r--protocols/Sametime/src/files.cpp4
-rw-r--r--protocols/Twitter/src/proto.cpp2
-rw-r--r--protocols/VKontakte/src/misc.cpp6
-rw-r--r--protocols/Yahoo/src/avatar.cpp6
-rw-r--r--src/core/stdauth/auth.cpp2
-rw-r--r--src/core/stdauth/authdialogs.cpp8
-rw-r--r--src/core/stdchat/src/window.cpp2
-rw-r--r--src/core/stdfile/filexferdlg.cpp4
-rw-r--r--src/core/stdmsg/src/msgdialog.cpp4
-rw-r--r--src/modules/chat/log.cpp2
-rw-r--r--src/modules/chat/tools.cpp4
-rw-r--r--src/modules/clist/clistmod.cpp2
-rw-r--r--src/modules/fonts/FontOptions.cpp4
-rw-r--r--src/modules/fonts/services.cpp6
-rw-r--r--src/modules/netlib/netlibautoproxy.cpp2
-rw-r--r--src/modules/skin/sounds.cpp2
-rw-r--r--src/modules/utils/bmpfilter.cpp2
-rw-r--r--src/modules/xml/xmlParser.cpp4
77 files changed, 232 insertions, 220 deletions
diff --git a/plugins/AdvaImg/src/main.cpp b/plugins/AdvaImg/src/main.cpp
index 9c7bdb698a..f522f8b499 100644
--- a/plugins/AdvaImg/src/main.cpp
+++ b/plugins/AdvaImg/src/main.cpp
@@ -294,7 +294,7 @@ static INT_PTR serviceBmpFilterResizeBitmap(WPARAM wParam,LPARAM lParam)
&& width > bminfo.bmWidth && height > bminfo.bmHeight))
{
// Do nothing
- return (int) info->hBmp;
+ return (INT_PTR)info->hBmp;
}
else
{
@@ -847,18 +847,18 @@ static INT_PTR serviceLoad(WPARAM wParam, LPARAM lParam)
// ok, let's load the file
FIBITMAP *dib;
- if(lParam & IMGL_WCHAR)
+ if (lParam & IMGL_WCHAR)
dib = FreeImage_LoadU(fif, (wchar_t *)lpszFilename, 0);
else
dib = FreeImage_Load(fif, lpszFilename, 0);
if(dib == NULL || (lParam & IMGL_RETURNDIB))
- return (int)dib;
+ return (INT_PTR)dib;
HBITMAP hbm = FreeImage_CreateHBITMAPFromDIB(dib);
FreeImage_Unload(dib);
FI_CorrectBitmap32Alpha(hbm, FALSE);
- return((INT_PTR)hbm);
+ return ((INT_PTR)hbm);
}
return NULL;
}
diff --git a/plugins/Alarms/src/alarms.cpp b/plugins/Alarms/src/alarms.cpp
index c3d3a8e1f7..cf8050f8ec 100644
--- a/plugins/Alarms/src/alarms.cpp
+++ b/plugins/Alarms/src/alarms.cpp
@@ -107,16 +107,16 @@ static int PluginMessageReceived(WPARAM wParam,LPARAM lParam)
TCHAR *savedMsg = ppre->tszMessage;
if (!_tcscmp(msg, _T(" ffw"))) {
- mir_sntprintf(buff, SIZEOF(buff), _T("%s"), _T("Fast forward!"));
+ _tcsncpy_s(buff, _T("Fast forward!"), _TRUNCATE);
HWND hWnd = FindWindow(0, _T("Windows Media Player"));
PostMessage(hWnd, WM_COMMAND, WMP_NEXT, 0);
- }
- else mir_sntprintf(buff, SIZEOF(buff), TranslateT("Unknown command issued: \"%s\""), msg);
+ } else
+ mir_sntprintf(buff, SIZEOF(buff), TranslateT("Unknown command issued: \"%s\""), msg);
ShowPopup(pccsd->hContact, buff);
- _tcsncpy(response, buff,SIZEOF(response));
+ _tcsncpy(response, buff, SIZEOF(response));
PluginSendMessage((WPARAM)pccsd->hContact, (LPARAM)response);
return 0;
diff --git a/plugins/BossKeyPlus/src/BossKey.cpp b/plugins/BossKeyPlus/src/BossKey.cpp
index 309713140c..572a1c364c 100644
--- a/plugins/BossKeyPlus/src/BossKey.cpp
+++ b/plugins/BossKeyPlus/src/BossKey.cpp
@@ -264,13 +264,11 @@ static void CreateTrayIcon(bool create)
{
NOTIFYICONDATA nim;
DBVARIANT dbVar;
- if (!db_get_ts(NULL,MOD_NAME,"ToolTipText",&dbVar))
- {
- mir_sntprintf(nim.szTip, 64, _T("%s"), dbVar.ptszVal);
+ if (!db_get_ts(NULL,MOD_NAME,"ToolTipText",&dbVar)) {
+ _tcsncpy_s(nim.szTip, dbVar.ptszVal, _TRUNCATE);
db_free(&dbVar);
- }
- else
- mir_tstrcpy(nim.szTip, _T("Miranda NG"));
+ } else
+ _tcsncpy_s(nim.szTip, _T("Miranda NG"), _TRUNCATE);
nim.cbSize = sizeof(nim);
nim.hWnd = g_hListenWindow;
diff --git a/plugins/ChangeKeyboardLayout/src/hook_events.cpp b/plugins/ChangeKeyboardLayout/src/hook_events.cpp
index 8253c9c7ab..9b8d53e7c9 100644
--- a/plugins/ChangeKeyboardLayout/src/hook_events.cpp
+++ b/plugins/ChangeKeyboardLayout/src/hook_events.cpp
@@ -9,7 +9,7 @@ INT_PTR APIChangeLayout(WPARAM wParam, LPARAM lParam)
INT_PTR APIGetLayoutOfText(WPARAM wParam, LPARAM lParam)
{
LPTSTR ptszInText = (TCHAR*)lParam;
- return (int) GetLayoutOfText(ptszInText);
+ return (INT_PTR)GetLayoutOfText(ptszInText);
}
INT_PTR APIChangeTextLayout(WPARAM wParam, LPARAM lParam)
diff --git a/plugins/Clist_modern/src/modern_cachefuncs.cpp b/plugins/Clist_modern/src/modern_cachefuncs.cpp
index a45d9a02dd..1b6fa8b40a 100644
--- a/plugins/Clist_modern/src/modern_cachefuncs.cpp
+++ b/plugins/Clist_modern/src/modern_cachefuncs.cpp
@@ -465,8 +465,8 @@ int Cache_GetLineText(
DBVARIANT dbv = {0};
// Try to get XStatusName
if (!db_get_ts(pdnce->hContact, pdnce->m_cache_cszProto, "XStatusName", &dbv)) {
- if (dbv.pszVal != NULL && dbv.pszVal[0] != 0)
- mir_sntprintf(text, text_size, _T("%s"), dbv.pszVal);
+ if (dbv.ptszVal != NULL && dbv.ptszVal[0] != 0)
+ _tcsncpy_s(text, text_size, dbv.ptszVal, _TRUNCATE);
CopySkipUnprintableChars(text, text, text_size-1);
db_free(&dbv);
}
diff --git a/plugins/Clist_modern/src/modern_clc.cpp b/plugins/Clist_modern/src/modern_clc.cpp
index c234b7d400..873020a36c 100644
--- a/plugins/Clist_modern/src/modern_clc.cpp
+++ b/plugins/Clist_modern/src/modern_clc.cpp
@@ -1365,7 +1365,7 @@ static LRESULT clcOnLButtonUp(ClcData *dat, HWND hwnd, UINT msg, WPARAM wParam,
if (sourceGrName)
mir_sntprintf(newName, SIZEOF(newName), _T("%s\\%s"), sourceGrName, shortGroup);
else
- mir_sntprintf(newName, SIZEOF(newName), _T("%s"), shortGroup);
+ _tcsncpy_s(newName, shortGroup, _TRUNCATE);
}
mir_free(groupName);
mir_free(sourceGrName);
diff --git a/plugins/Clist_modern/src/modern_rowtemplateopt.cpp b/plugins/Clist_modern/src/modern_rowtemplateopt.cpp
index 97be36e25a..66581b5271 100644
--- a/plugins/Clist_modern/src/modern_rowtemplateopt.cpp
+++ b/plugins/Clist_modern/src/modern_rowtemplateopt.cpp
@@ -315,14 +315,14 @@ void RefreshTree(HWND hwndDlg,HTREEITEM hti)
if (!cell->child)
{
if (cell->type == 0)
- mir_sntprintf(buf, SIZEOF(buf), TranslateT("Empty %s cell"), cell->cont == TC_COL?TranslateT("column"):TranslateT("line"));
+ mir_sntprintf(buf, SIZEOF(buf), TranslateT("Empty %s cell"), cell->cont == TC_COL ? TranslateT("column") : TranslateT("line"));
else
- mir_sntprintf(buf, SIZEOF(buf), _T("%s"), TranslateTS(types[cell->type]));
+ _tcsncpy_s(buf, TranslateTS(types[cell->type]), _TRUNCATE);
}
else
{
if (cell->type == 0)
- mir_sntprintf(buf, SIZEOF(buf), _T("%s"), cell->cont != TC_COL?TranslateT("columns"):TranslateT("lines"));
+ _tcsncpy_s(buf, (cell->cont != TC_COL ? TranslateT("columns") : TranslateT("lines")), _TRUNCATE);
else
mir_sntprintf(buf, SIZEOF(buf), TranslateT("%s, contain %s"), TranslateTS(types[cell->type]),cell->cont != TC_COL?TranslateT("columns"):TranslateT("lines"));
}
diff --git a/plugins/Clist_nicer/src/CLUIFrames/cluiframes.cpp b/plugins/Clist_nicer/src/CLUIFrames/cluiframes.cpp
index 3a18f1ba92..2a3d4829ee 100644
--- a/plugins/Clist_nicer/src/CLUIFrames/cluiframes.cpp
+++ b/plugins/Clist_nicer/src/CLUIFrames/cluiframes.cpp
@@ -918,7 +918,7 @@ INT_PTR CLUIFramesGetFrameOptions(WPARAM wParam, LPARAM lParam)
return (INT_PTR)Frames[pos].align;
case FO_FLOATING:
- return (int)Frames[pos].floating;
+ return (INT_PTR)Frames[pos].floating;
case FO_FLAGS:
INT_PTR dwFlags = 0;
diff --git a/plugins/Clist_nicer/src/clcutils.cpp b/plugins/Clist_nicer/src/clcutils.cpp
index 3b0019626c..c700c5607c 100644
--- a/plugins/Clist_nicer/src/clcutils.cpp
+++ b/plugins/Clist_nicer/src/clcutils.cpp
@@ -48,38 +48,52 @@ static int MY_pathIsAbsolute(const TCHAR *path)
size_t MY_pathToRelative(const TCHAR *pSrc, TCHAR *pOut)
{
- if ( !pSrc || !mir_tstrlen(pSrc) || mir_tstrlen(pSrc) > MAX_PATH)
- return 0;
+ size_t dwSrcLen, dwProfilePathLen;
- if ( !MY_pathIsAbsolute(pSrc)) {
- mir_sntprintf(pOut, MAX_PATH, _T("%s"), pSrc);
- return mir_tstrlen(pOut);
- }
+ if (!pSrc || !pOut)
+ return 0;
+ dwSrcLen = mir_tstrlen(pSrc);
+ if (!dwSrcLen || dwSrcLen > (MAX_PATH - 1))
+ return 0;
+ if (!MY_pathIsAbsolute(pSrc))
+ goto path_not_abs;
TCHAR szTmp[MAX_PATH];
- mir_sntprintf(szTmp, SIZEOF(szTmp), _T("%s"), pSrc);
+ memcpy(szTmp, pSrc, (dwSrcLen * sizeof(TCHAR)));
+ szTmp[dwSrcLen] = 0;
_tcslwr(szTmp);
- if ( _tcsstr(szTmp, cfg::dat.tszProfilePath)) {
- mir_sntprintf(pOut, MAX_PATH, _T("%s"), pSrc + mir_tstrlen(cfg::dat.tszProfilePath) - 1);
- pOut[0]='.';
- return mir_tstrlen(pOut);
- }
-
- mir_sntprintf(pOut, MAX_PATH, _T("%s"), pSrc);
- return mir_tstrlen(pOut);
+ if (_tcsstr(szTmp, cfg::dat.tszProfilePath)) {
+ dwProfilePathLen = mir_tstrlen(cfg::dat.tszProfilePath);
+ memcpy(pOut, (pSrc + (dwProfilePathLen - 1)), ((dwSrcLen - (dwProfilePathLen - 1)) * sizeof(TCHAR)));
+ pOut[0] = '.';
+ pOut[dwSrcLen] = 0;
+ return (dwSrcLen - (dwProfilePathLen - 1));
+ }
+
+path_not_abs:
+ memcpy(pOut, pSrc, (dwSrcLen * sizeof(TCHAR)));
+ pOut[dwSrcLen] = 0;
+ return dwSrcLen;
}
size_t MY_pathToAbsolute(const TCHAR *pSrc, TCHAR *pOut)
{
- if ( !pSrc || !mir_tstrlen(pSrc) || mir_tstrlen(pSrc) > MAX_PATH)
+ size_t dwSrcLen;
+
+ if (!pSrc || !pOut)
+ return 0;
+ dwSrcLen = mir_tstrlen(pSrc);
+ if (!dwSrcLen || dwSrcLen > (MAX_PATH - 1))
return 0;
- if (MY_pathIsAbsolute(pSrc)&&pSrc[0]!='.')
- mir_sntprintf(pOut, MAX_PATH, _T("%s"), pSrc);
- else if (pSrc[0]=='.')
- mir_sntprintf(pOut, MAX_PATH, _T("%s\\%s"), cfg::dat.tszProfilePath, pSrc);
+ if (MY_pathIsAbsolute(pSrc) && pSrc[0] != '.') {
+ memcpy(pOut, pSrc, (dwSrcLen * sizeof(TCHAR)));
+ pOut[dwSrcLen] = 0;
+ return dwSrcLen;
+ if (pSrc[0] == '.')
+ return (mir_sntprintf(pOut, MAX_PATH, _T("%s\\%s"), cfg::dat.tszProfilePath, pSrc));
- return mir_tstrlen(pOut);
+ return 0;
}
/*
diff --git a/plugins/ConnectionNotify/src/ConnectionNotify.cpp b/plugins/ConnectionNotify/src/ConnectionNotify.cpp
index 0513ea98a6..1a42fb6794 100644
--- a/plugins/ConnectionNotify/src/ConnectionNotify.cpp
+++ b/plugins/ConnectionNotify/src/ConnectionNotify.cpp
@@ -639,7 +639,7 @@ INT_PTR TMLoadIcon(WPARAM wParam,LPARAM lParam)
case PLI_OFFLINE: id=IDI_ICON2; break;
default: return 0;
}
- return (int)LoadImage(hInst, MAKEINTRESOURCE(id), IMAGE_ICON, GetSystemMetrics(wParam&PLIF_SMALL?SM_CXSMICON:SM_CXICON), GetSystemMetrics(wParam&PLIF_SMALL?SM_CYSMICON:SM_CYICON), 0);
+ return (INT_PTR)LoadImage(hInst, MAKEINTRESOURCE(id), IMAGE_ICON, GetSystemMetrics(wParam&PLIF_SMALL?SM_CXSMICON:SM_CXICON), GetSystemMetrics(wParam&PLIF_SMALL?SM_CYSMICON:SM_CYICON), 0);
}
//=======================================================
//SetStatus
@@ -816,11 +816,11 @@ void showMsg(TCHAR *pName, DWORD pid,TCHAR *intIp,TCHAR *extIp,int intPort,int e
}
ppd.PluginWindowProc = PopupDlgProc;
- ppd.iSeconds=settingInterval1;
+ ppd.iSeconds = settingInterval1;
//Now the "additional" data.
- mir_sntprintf(mpd->strIntIp,_countof(mpd->strIntIp),_T("%s"),intIp);
- mir_sntprintf(mpd->strExtIp,_countof(mpd->strExtIp),_T("%s"),extIp);
- mir_sntprintf(mpd->PName,_countof(mpd->PName),_T("%s"),pName);
+ _tcsncpy_s(mpd->strIntIp, intIp, _TRUNCATE);
+ _tcsncpy_s(mpd->strExtIp, extIp, _TRUNCATE);
+ _tcsncpy_s(mpd->PName, pName, _TRUNCATE);
mpd->intIntPort = intPort;
mpd->intExtPort = extPort;
mpd->Pid = pid;
diff --git a/plugins/CrashDumper/src/crshdmp.cpp b/plugins/CrashDumper/src/crshdmp.cpp
index ccc560205a..b00edd0437 100644
--- a/plugins/CrashDumper/src/crshdmp.cpp
+++ b/plugins/CrashDumper/src/crshdmp.cpp
@@ -375,7 +375,7 @@ extern "C" int __declspec(dllexport) Load(void)
profpath = Utils_ReplaceVarsT(_T("%miranda_userdata%"));
if (catchcrashes && !needrestart)
mir_sntprintf(CrashLogFolder, MAX_PATH, TEXT("%s\\CrashLog"), profpath);
- mir_sntprintf(VersionInfoFolder, MAX_PATH, TEXT("%s"), profpath);
+ _tcsncpy_s(VersionInfoFolder, profpath, _TRUNCATE);
HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded);
diff --git a/plugins/ExternalAPI/m_folders.h b/plugins/ExternalAPI/m_folders.h
index e2fc98626a..c54f7c3d18 100644
--- a/plugins/ExternalAPI/m_folders.h
+++ b/plugins/ExternalAPI/m_folders.h
@@ -189,7 +189,7 @@ __inline static INT_PTR FoldersGetCustomPathW(HANDLE hFolderEntry, wchar_t *path
if (res) {
wchar_t buffer[MAX_PATH];
PathToAbsoluteW(notFoundW, buffer);
- mir_sntprintf(pathW, size, _T("%s"), buffer);
+ _tcsncpy_s(pathW, size, buffer, _TRUNCATE);
}
return res;
@@ -228,7 +228,7 @@ __inline static INT_PTR FoldersGetCustomPathExW(HANDLE hFolderEntry, wchar_t *pa
if (res) {
wchar_t buffer[MAX_PATH];
PathToAbsoluteW(notFoundW, buffer);
- mir_sntprintf(pathW, size, _T("%s"), buffer);
+ wcsncpy_s(pathW, size, buffer, _TRUNCATE);
}
if (pathW[0] != '\0')
diff --git a/plugins/FingerprintNG/src/fingerprint.cpp b/plugins/FingerprintNG/src/fingerprint.cpp
index 650ca060c2..d095f6e8a5 100644
--- a/plugins/FingerprintNG/src/fingerprint.cpp
+++ b/plugins/FingerprintNG/src/fingerprint.cpp
@@ -67,7 +67,7 @@ void __fastcall Prepare(KN_FP_MASK* mask, bool bEnable)
if (mask->iIconIndex == IDI_NOTFOUND || mask->iIconIndex == IDI_UNKNOWN || mask->iIconIndex == IDI_UNDETECTED)
GetModuleFileName(g_hInst, destfile, MAX_PATH);
else {
- mir_sntprintf(destfile, SIZEOF(destfile), _T("%s"), g_szSkinLib);
+ _tcsncpy_s(destfile, g_szSkinLib, _TRUNCATE);
struct _stat64i32 stFileInfo;
if ( _tstat(destfile, &stFileInfo) == -1)
@@ -256,7 +256,7 @@ static void MatchMasks(TCHAR* szMirVer, short *base, short *overlay, short *over
if (p.iIconIndex != IDI_NOTFOUND && p.iIconIndex != IDI_UNKNOWN && p.iIconIndex != IDI_UNDETECTED) {
TCHAR destfile[MAX_PATH];
- mir_sntprintf(destfile, SIZEOF(destfile), _T("%s"), g_szSkinLib);
+ _tcsncpy_s(destfile, g_szSkinLib, _TRUNCATE);
struct _stat64i32 stFileInfo;
if ( _tstat(destfile, &stFileInfo) == -1)
diff --git a/plugins/Folders/src/utils.cpp b/plugins/Folders/src/utils.cpp
index e21a820325..a2ba6668d7 100644
--- a/plugins/Folders/src/utils.cpp
+++ b/plugins/Folders/src/utils.cpp
@@ -127,7 +127,7 @@ wchar_t *StrReplace(wchar_t *source, const wchar_t *what, const wchar_t *withWha
char *StrTrim(char *szText, const char *szTrimChars)
{
- int i = (int)strlen(szText) - 1;
+ size_t i = strlen(szText) - 1;
while (i >= 0 && strchr(szTrimChars, szText[i]))
szText[i--] = '\0';
@@ -143,7 +143,7 @@ char *StrTrim(char *szText, const char *szTrimChars)
wchar_t *StrTrim(wchar_t *szText, const wchar_t *szTrimChars)
{
- int i = (int)wcslen(szText) - 1;
+ size_t i = wcslen(szText) - 1;
while (i >= 0 && wcschr(szTrimChars, szText[i]))
szText[i--] = '\0';
diff --git a/plugins/IEView/src/TemplateHTMLBuilder.cpp b/plugins/IEView/src/TemplateHTMLBuilder.cpp
index df42325586..c45ac7e528 100644
--- a/plugins/IEView/src/TemplateHTMLBuilder.cpp
+++ b/plugins/IEView/src/TemplateHTMLBuilder.cpp
@@ -195,7 +195,7 @@ void TemplateHTMLBuilder::buildHeadTemplate(IEView *view, IEVIEWEVENT *event, Pr
}
mir_snprintf(tempStr, SIZEOF(tempStr), "%snoavatar.png", tempBase);
TCHAR szNoAvatarPath[MAX_PATH];
- mir_sntprintf(szNoAvatarPath, SIZEOF(szNoAvatarPath), _T("%s"), _A2T(protoSettings->getSRMMTemplateFilename()));
+ _tcsncpy_s(szNoAvatarPath, _A2T(protoSettings->getSRMMTemplateFilename()), _TRUNCATE);
TCHAR *szNoAvatarPathTmp = _tcsrchr(szNoAvatarPath, '\\');
if (szNoAvatarPathTmp != NULL)
*szNoAvatarPathTmp = 0;
@@ -370,7 +370,7 @@ void TemplateHTMLBuilder::appendEventTemplate(IEView *view, IEVIEWEVENT *event,
}
TCHAR szNoAvatarPath[MAX_PATH];
- mir_sntprintf(szNoAvatarPath, SIZEOF(szNoAvatarPath), _T("%s"), _A2T(protoSettings->getSRMMTemplateFilename()));
+ _tcsncpy_s(szNoAvatarPath, _A2T(protoSettings->getSRMMTemplateFilename()), _TRUNCATE);
TCHAR *szNoAvatarPathTmp = _tcsrchr(szNoAvatarPath, '\\');
if (szNoAvatarPathTmp != NULL)
*szNoAvatarPathTmp = 0;
diff --git a/plugins/IEView/src/ieview_services.cpp b/plugins/IEView/src/ieview_services.cpp
index fb0545bebc..8c5f3f0d4b 100644
--- a/plugins/IEView/src/ieview_services.cpp
+++ b/plugins/IEView/src/ieview_services.cpp
@@ -84,7 +84,7 @@ INT_PTR HandleIEEvent(WPARAM, LPARAM lParam)
else if (event->iType == IEE_CLEAR_LOG)
view->clear(event);
else if (event->iType == IEE_GET_SELECTION)
- return (int)view->getSelection(event);
+ return (INT_PTR)view->getSelection(event);
else if (event->iType == IEE_SAVE_DOCUMENT)
view->saveDocument();
else if (event->iType == IEE_LOG_MEM_EVENTS)
diff --git a/plugins/KeyboardNotify/src/main.cpp b/plugins/KeyboardNotify/src/main.cpp
index 1d959950df..cbcdc60627 100644
--- a/plugins/KeyboardNotify/src/main.cpp
+++ b/plugins/KeyboardNotify/src/main.cpp
@@ -495,12 +495,12 @@ static INT_PTR IsFlashingActiveService(WPARAM, LPARAM)
INT_PTR NormalizeSequenceService(WPARAM wParam, LPARAM lParam)
{
- TCHAR strAux[MAX_PATH+1], *strIn = (TCHAR *)lParam;
+ TCHAR strAux[MAX_PATH + 1], *strIn = (TCHAR*)lParam;
- mir_sntprintf(strAux, MAX_PATH, _T("%s"), strIn);
- mir_sntprintf(strIn, MAX_PATH, _T("%s"), normalizeCustomString(strAux));
+ _tcsncpy_s(strAux, strIn, _TRUNCATE);
+ _tcsncpy_s(strIn, MAX_PATH, normalizeCustomString(strAux), _TRUNCATE);
- return (int)strIn;
+ return (INT_PTR)strIn;
}
@@ -698,10 +698,10 @@ void createEventPrefix(TCHAR *prefixName, size_t maxLen)
while (str = _tcschr(profileName, _T('\\')))
*str = _T('/');
if ((len = _tcslen(profileName)) <= maxLen)
- _tcscpy(prefixName, profileName);
+ _tcsncpy_s(prefixName, maxLen, profileName, _TRUNCATE);
else {
str = profileName + len - maxLen / 2;
- mir_sntprintf(prefixName, maxLen / 2, _T("%s"), profileName);
+ _tcsncpy_s(prefixName, (maxLen / 2), profileName, _TRUNCATE);
_tcscat(prefixName, str);
}
}
diff --git a/plugins/NewAwaySysMod/src/Services.cpp b/plugins/NewAwaySysMod/src/Services.cpp
index a1f2c42840..dfe711c77f 100644
--- a/plugins/NewAwaySysMod/src/Services.cpp
+++ b/plugins/NewAwaySysMod/src/Services.cpp
@@ -172,7 +172,7 @@ INT_PTR InvokeStatusWindow(WPARAM wParam, LPARAM)
if (g_SetAwayMsgPage.GetWnd()) { // already setting something
SetForegroundWindow(g_SetAwayMsgPage.GetWnd());
- return (int)g_SetAwayMsgPage.GetWnd();
+ return (INT_PTR)g_SetAwayMsgPage.GetWnd();
}
SetAwayMsgData *dat = new SetAwayMsgData;
memset(dat, 0, sizeof(SetAwayMsgData));
diff --git a/plugins/New_GPG/src/main.cpp b/plugins/New_GPG/src/main.cpp
index ae5785ea2b..9d09305217 100755
--- a/plugins/New_GPG/src/main.cpp
+++ b/plugins/New_GPG/src/main.cpp
@@ -154,19 +154,18 @@ static INT_PTR CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPAR
{
boost::posix_time::ptime now = boost::posix_time::second_clock::local_time();
TCHAR buf[5];
- mir_sntprintf(buf, 5, _T("%s"), expire_date);
+ _tcsncpy_s(buf, expire_date, _TRUNCATE);
int year = _ttoi(buf);
if(year < now.date().year())
expired = true;
else if(year == now.date().year())
{
- mir_sntprintf(buf, 3, _T("%s"), expire_date+5);
+ _tcsncpy_s(buf, (expire_date + 5), _TRUNCATE);
int month = _ttoi(buf);
if(month < now.date().month())
expired = true;
- else if(month == now.date().month())
- {
- mir_sntprintf(buf, 3, _T("%s"), expire_date+8);
+ else if(month == now.date().month()) {
+ _tcsncpy_s(buf, (expire_date + 8), _TRUNCATE);
unsigned day = _ttoi(buf);
if(day <= now.date().day_number())
expired = true;
@@ -2125,19 +2124,19 @@ void InitCheck()
{
boost::posix_time::ptime now = boost::posix_time::second_clock::local_time();
TCHAR buf[5];
- mir_sntprintf(buf, 5, _T("%s"), expire_date);
+ _tcsncpy_s(buf, expire_date, _TRUNCATE);
int year = _ttoi(buf);
if(year < now.date().year())
expired = true;
else if(year == now.date().year())
{
- mir_sntprintf(buf, 3, _T("%s"), expire_date+5);
+ _tcsncpy_s(buf, (expire_date + 5), _TRUNCATE);
int month = _ttoi(buf);
if(month < now.date().month())
expired = true;
else if(month == now.date().month())
{
- mir_sntprintf(buf, 3, _T("%s"), expire_date+8);
+ _tcsncpy_s(buf, (expire_date + 8), _TRUNCATE);
unsigned day = _ttoi(buf);
if(day <= now.date().day_number())
expired = true;
@@ -2192,19 +2191,19 @@ void InitCheck()
{
boost::posix_time::ptime now = boost::posix_time::second_clock::local_time();
TCHAR buf[5];
- mir_sntprintf(buf, 5, _T("%s"), expire_date);
+ _tcsncpy_s(buf, expire_date, _TRUNCATE);
int year = _ttoi(buf);
if(year < now.date().year())
expired = true;
else if(year == now.date().year())
{
- mir_sntprintf(buf, 3, _T("%s"), expire_date+5);
+ _tcsncpy_s(buf, (expire_date + 5), _TRUNCATE);
int month = _ttoi(buf);
if(month < now.date().month())
expired = true;
else if(month == now.date().month())
{
- mir_sntprintf(buf, 3, _T("%s"), expire_date+8);
+ _tcsncpy_s(buf, (expire_date + 8), _TRUNCATE);
unsigned day = _ttoi(buf);
if(day <= now.date().day_number())
expired = true;
diff --git a/plugins/NotesAndReminders/src/reminders.cpp b/plugins/NotesAndReminders/src/reminders.cpp
index 06f9ec8396..e6e2b35639 100644
--- a/plugins/NotesAndReminders/src/reminders.cpp
+++ b/plugins/NotesAndReminders/src/reminders.cpp
@@ -1017,7 +1017,7 @@ static BOOL ParseTime(LPCSTR s, int *hout, int *mout, BOOL bTimeOffset, BOOL bAl
// returns TRUE if combo box list displays time offsets ("23:34 (5 Minutes)" etc.)
__inline static BOOL IsRelativeCombo(HWND Dialog, UINT nIDTime)
{
- return (int)SendDlgItemMessage(Dialog,nIDTime,CB_GETITEMDATA,0,0) >= 0;
+ return (((int)SendDlgItemMessage(Dialog,nIDTime,CB_GETITEMDATA,0,0)) >= 0);
}
static void PopulateTimeCombo(HWND Dialog, UINT nIDTime, BOOL bRelative, const SYSTEMTIME *tmUtc)
diff --git a/plugins/Scriver/src/infobar.cpp b/plugins/Scriver/src/infobar.cpp
index 8917bb1d78..c2e53271c8 100644
--- a/plugins/Scriver/src/infobar.cpp
+++ b/plugins/Scriver/src/infobar.cpp
@@ -79,9 +79,9 @@ void RefreshInfobar(InfobarWindowData* idat)
TCHAR szText[2048];
SETTEXTEX st;
if ( szXStatusMsg && *szXStatusMsg )
- mir_sntprintf(szText, 2047, _T("%s (%s)"), TranslateTS(szXStatusName), szXStatusMsg);
+ mir_sntprintf(szText, SIZEOF(szText), _T("%s (%s)"), TranslateTS(szXStatusName), szXStatusMsg);
else
- mir_sntprintf(szText, 2047, _T("%s"), TranslateTS(szXStatusName));
+ _tcsncpy_s(szText, TranslateTS(szXStatusName), _TRUNCATE);
st.flags = ST_DEFAULT;
st.codepage = 1200;
SendDlgItemMessage(hwnd, IDC_INFOBAR_NAME, EM_SETTEXTEX, (WPARAM) &st, (LPARAM)szContactName);
diff --git a/plugins/Scriver/src/msgoptions.cpp b/plugins/Scriver/src/msgoptions.cpp
index 0f0a8d85a4..682bf76cbe 100644
--- a/plugins/Scriver/src/msgoptions.cpp
+++ b/plugins/Scriver/src/msgoptions.cpp
@@ -112,8 +112,8 @@ void RegisterFontServiceFonts()
{
int i;
FontIDT fid = { sizeof(fid) };
- mir_sntprintf(fid.group, SIZEOF(fid.group), _T("%s"), LPGENT("Messaging"));
- mir_sntprintf(fid.backgroundGroup, SIZEOF(fid.backgroundGroup), _T("%s"), LPGENT("Messaging"));
+ _tcsncpy_s(fid.group, LPGENT("Messaging"), _TRUNCATE);
+ _tcsncpy_s(fid.backgroundGroup, LPGENT("Messaging"), _TRUNCATE);
strncpy(fid.dbSettingsGroup, SRMMMOD, SIZEOF(fid.dbSettingsGroup));
fid.flags = FIDF_DEFAULTVALID | FIDF_DEFAULTVALID;
for (i = 0; i < SIZEOF(fontOptionsList); i++) {
@@ -133,7 +133,7 @@ void RegisterFontServiceFonts()
}
ColourIDT cid = { sizeof(cid) };
- mir_sntprintf(cid.group, SIZEOF(cid.group), _T("%s"), LPGENT("Messaging"));
+ _tcsncpy_s(cid.group, LPGENT("Messaging"), _TRUNCATE);
strncpy(cid.dbSettingsGroup, SRMMMOD, SIZEOF(fid.dbSettingsGroup));
cid.flags = 0;
for (i = 0; i < SIZEOF(colourOptionsList); i++) {
diff --git a/plugins/Scriver/src/msgtimedout.cpp b/plugins/Scriver/src/msgtimedout.cpp
index 317d8b6ef4..6a7bc06f49 100644
--- a/plugins/Scriver/src/msgtimedout.cpp
+++ b/plugins/Scriver/src/msgtimedout.cpp
@@ -52,7 +52,7 @@ INT_PTR CALLBACK ErrorDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar
if (ewd->szName)
mir_sntprintf(szText, SIZEOF(szText), _T("%s - %s"), TranslateT("Send Error"), ewd->szName);
else
- mir_sntprintf(szText, SIZEOF(szText), _T("%s"), TranslateT("Send Error"));
+ _tcsncpy_s(szText, TranslateT("Send Error"), _TRUNCATE);
SetWindowText(hwndDlg, szText);
GetWindowRect(hwndDlg, &rc);
diff --git a/plugins/SimpleStatusMsg/src/awaymsg.cpp b/plugins/SimpleStatusMsg/src/awaymsg.cpp
index 84a8acda74..3f7c677730 100644
--- a/plugins/SimpleStatusMsg/src/awaymsg.cpp
+++ b/plugins/SimpleStatusMsg/src/awaymsg.cpp
@@ -266,7 +266,7 @@ static INT_PTR CALLBACK CopyAwayMsgDlgProc(HWND hwndDlg, UINT message, WPARAM wP
if (EmptyClipboard()) {
TCHAR msg[1024];
TCHAR *tszMsg = StrNormNewline((TCHAR *)ack->lParam);
- mir_sntprintf(msg, SIZEOF(msg), _T("%s"), tszMsg);
+ _tcsncpy_s(msg, tszMsg, _TRUNCATE);
mir_free(tszMsg);
size_t len = mir_tstrlen(msg);
if (len) {
diff --git a/plugins/Spamotron/src/popups.cpp b/plugins/Spamotron/src/popups.cpp
index 43a5ee5655..3635aa33bc 100644
--- a/plugins/Spamotron/src/popups.cpp
+++ b/plugins/Spamotron/src/popups.cpp
@@ -184,10 +184,10 @@ int ShowPopupPreview(HWND optDlg, BYTE popupType, TCHAR *line1, TCHAR *line2)
if (SendDlgItemMessage(optDlg, IDC_OPT_POPUPS_DEFAULT_TIMEOUT, BM_GETCHECK, 0, 0) || popupType == POPUP_DEFAULT)
ppdp.iSeconds = 0;
- ppdp.lchContact = NULL;
- mir_sntprintf(ppdp.lptzContactName, MAX_CONTACTNAME, _T("%s"), (line1)?line1:_T(PLUGIN_NAME));
+ ppdp.lchContact = NULL;
+ _tcsncpy_s(ppdp.lptzContactName, (line1 ? line1 : _T(PLUGIN_NAME)), _TRUNCATE);
if (line2)
- mir_sntprintf(ppdp.lptzText, MAX_SECONDLINE, _T("%s"), line2);
+ _tcsncpy_s(ppdp.lptzText, line2, _TRUNCATE);
return PUAddPopupT(&ppdp);
}
@@ -233,9 +233,9 @@ int ShowPopup(MCONTACT hContact, BYTE popupType, TCHAR *line1, TCHAR *line2)
if (_getOptB("PopupDefaultTimeout", defaultPopupDefaultTimeout) || popupType == POPUP_DEFAULT)
ppdp.iSeconds = 0;
- ppdp.lchContact = hContact;
- mir_sntprintf(ppdp.lptzContactName, MAX_CONTACTNAME, _T("%s"), (line1)?line1:_T(PLUGIN_NAME));
+ ppdp.lchContact = hContact;
+ _tcsncpy_s(ppdp.lptzContactName, (line1 ? line1 : _T(PLUGIN_NAME)), _TRUNCATE);
if (line2)
- mir_sntprintf(ppdp.lptzText, MAX_SECONDLINE, _T("%s"), line2);
+ _tcsncpy_s(ppdp.lptzText, line2, _TRUNCATE);
return PUAddPopupT(&ppdp);
} \ No newline at end of file
diff --git a/plugins/TabSRMM/src/chat/log.cpp b/plugins/TabSRMM/src/chat/log.cpp
index 7129dc6361..cee377f6ca 100644
--- a/plugins/TabSRMM/src/chat/log.cpp
+++ b/plugins/TabSRMM/src/chat/log.cpp
@@ -629,7 +629,7 @@ static void AddEventToBuffer(char **buffer, int *bufferEnd, int *bufferAlloced,
if (streamData->lin->ptszUserInfo && streamData->lin->iType != GC_EVENT_TOPIC)
mir_sntprintf(szTemp, SIZEOF(szTemp), _T("%s (%s)"), szTemp2, streamData->lin->ptszUserInfo);
else
- mir_sntprintf(szTemp, SIZEOF(szTemp), _T("%s"), szTemp2);
+ _tcsncpy_s(szTemp, szTemp2, _TRUNCATE);
pszNick = szTemp;
}
diff --git a/plugins/TabSRMM/src/chat/main.cpp b/plugins/TabSRMM/src/chat/main.cpp
index 9efe0eb1c4..994a7feabe 100644
--- a/plugins/TabSRMM/src/chat/main.cpp
+++ b/plugins/TabSRMM/src/chat/main.cpp
@@ -47,7 +47,7 @@ static void OnGetLogName(SESSION_INFO *si, LPCTSTR ptszParsedName)
if (!PathIsAbsoluteT(ptszParsedName))
mir_sntprintf(si->pszLogFileName, MAX_PATH, _T("%s%s"), M.getChatLogPath(), ptszParsedName);
else
- mir_sntprintf(si->pszLogFileName, MAX_PATH, _T("%s"), ptszParsedName);
+ _tcsncpy_s(si->pszLogFileName, ptszParsedName, _TRUNCATE);
}
static void OnCreateSession(SESSION_INFO *si, MODULEINFO *mi)
diff --git a/plugins/TabSRMM/src/chat/options.cpp b/plugins/TabSRMM/src/chat/options.cpp
index dc89da275f..d4fb1228dc 100644
--- a/plugins/TabSRMM/src/chat/options.cpp
+++ b/plugins/TabSRMM/src/chat/options.cpp
@@ -831,7 +831,7 @@ INT_PTR CALLBACK DlgProcOptions2(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM
case IDC_MUC_OPENLOGBASEDIR:
{
TCHAR tszTemp[MAX_PATH + 20];
- mir_sntprintf(tszTemp, MAX_PATH + 20, _T("%s"), g_Settings.pszLogDir);
+ _tcsncpy_s(tszTemp, g_Settings.pszLogDir, _TRUNCATE);
TCHAR *p = tszTemp;
while(*p && (*p == '\\' || *p == '.'))
@@ -841,10 +841,10 @@ INT_PTR CALLBACK DlgProcOptions2(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM
if (TCHAR *p1 = _tcschr(p, '\\'))
*p1 = 0;
- TCHAR tszInitialDir[_MAX_DRIVE + _MAX_PATH + 10];
- mir_sntprintf(tszInitialDir, MAX_PATH, _T("%s%s"), M.getChatLogPath(), p);
+ TCHAR tszInitialDir[_MAX_DRIVE + _MAX_PATH + 10];
+ mir_sntprintf(tszInitialDir, SIZEOF(tszInitialDir), _T("%s%s"), M.getChatLogPath(), p);
if (!PathFileExists(tszInitialDir))
- mir_sntprintf(tszInitialDir, MAX_PATH, _T("%s"), M.getChatLogPath());
+ _tcsncpy_s(tszInitialDir, M.getChatLogPath(), _TRUNCATE);
TCHAR tszReturnName[MAX_PATH]; tszReturnName[0] = 0;
mir_sntprintf(tszTemp, SIZEOF(tszTemp), _T("%s%c*.*%c%c"), TranslateT("All Files"), 0, 0, 0);
diff --git a/plugins/TabSRMM/src/contactcache.cpp b/plugins/TabSRMM/src/contactcache.cpp
index 3272c5610c..650f3ceb7b 100644
--- a/plugins/TabSRMM/src/contactcache.cpp
+++ b/plugins/TabSRMM/src/contactcache.cpp
@@ -122,7 +122,7 @@ bool CContactCache::updateNick()
TCHAR *tszNick = pcli->pfnGetContactDisplayName(getActiveContact(), 0);
if (tszNick)
fChanged = (_tcscmp(m_szNick, tszNick) ? true : false);
- mir_sntprintf(m_szNick, 80, _T("%s"), tszNick ? tszNick : _T("<undef>"));
+ _tcsncpy_s(m_szNick, (tszNick ? tszNick : _T("<undef>")), _TRUNCATE);
}
return fChanged;
}
@@ -187,8 +187,8 @@ bool CContactCache::updateUIN()
if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci)) {
switch (ci.type) {
case CNFT_ASCIIZ:
- mir_sntprintf(m_szUIN, SIZEOF(m_szUIN), _T("%s"), reinterpret_cast<TCHAR *>(ci.pszVal));
- mir_free((void*)ci.pszVal);
+ _tcsncpy_s(m_szUIN, ci.pszVal, _TRUNCATE);
+ mir_free(ci.pszVal);
break;
case CNFT_DWORD:
mir_sntprintf(m_szUIN, SIZEOF(m_szUIN), _T("%u"), ci.dVal);
diff --git a/plugins/TabSRMM/src/container.cpp b/plugins/TabSRMM/src/container.cpp
index 7239a16651..45ddd99900 100644
--- a/plugins/TabSRMM/src/container.cpp
+++ b/plugins/TabSRMM/src/container.cpp
@@ -1464,7 +1464,7 @@ panel_found:
if (szThemeName != NULL) {
PathToAbsoluteT(szThemeName, pContainer->szAbsThemeFile, M.getDataPath());
- mir_sntprintf(pContainer->szRelThemeFile, MAX_PATH, _T("%s"), szThemeName);
+ _tcsncpy_s(pContainer->szRelThemeFile, szThemeName, _TRUNCATE);
db_free(&dbv);
}
else pContainer->szAbsThemeFile[0] = pContainer->szRelThemeFile[0] = 0;
diff --git a/plugins/TabSRMM/src/containeroptions.cpp b/plugins/TabSRMM/src/containeroptions.cpp
index 8c43d1b53e..5cd8f77982 100644
--- a/plugins/TabSRMM/src/containeroptions.cpp
+++ b/plugins/TabSRMM/src/containeroptions.cpp
@@ -349,7 +349,7 @@ INT_PTR CALLBACK DlgProcContainerOptions(HWND hwndDlg, UINT msg, WPARAM wParam,
pContainer->fPrivateThemeChanged = TRUE;
if (PathFileExists(szFinalThemeFile))
- mir_sntprintf(pContainer->szRelThemeFile, MAX_PATH, _T("%s"), szFilename);
+ _tcsncpy_s(pContainer->szRelThemeFile, szFilename, _TRUNCATE);
else
pContainer->szRelThemeFile[0] = 0;
}
diff --git a/plugins/TabSRMM/src/controls.cpp b/plugins/TabSRMM/src/controls.cpp
index 96250381fa..db00db12b9 100644
--- a/plugins/TabSRMM/src/controls.cpp
+++ b/plugins/TabSRMM/src/controls.cpp
@@ -981,7 +981,7 @@ LONG_PTR CALLBACK StatusBarSubclassProc(HWND hWnd, UINT msg, WPARAM wParam, LPAR
mtnStatus ? TranslateT("enabled") : TranslateT("disabled"));
}
else if (sid->dwId == MSG_ICON_SESSION)
- mir_sntprintf(wBuf, SIZEOF(wBuf), _T("%s"), TranslateT("Session list.\nClick left for a list of open sessions.\nClick right to access favorites and quickly configure message window behavior"));
+ _tcsncpy_s(wBuf, TranslateT("Session list.\nClick left for a list of open sessions.\nClick right to access favorites and quickly configure message window behavior"), _TRUNCATE);
}
else if (sid->tszTooltip)
_tcsncpy(wBuf, sid->tszTooltip, SIZEOF(wBuf));
diff --git a/plugins/TabSRMM/src/eventpopups.cpp b/plugins/TabSRMM/src/eventpopups.cpp
index 3ba4c3e360..d3d6953c78 100644
--- a/plugins/TabSRMM/src/eventpopups.cpp
+++ b/plugins/TabSRMM/src/eventpopups.cpp
@@ -678,13 +678,13 @@ static int PopupShowT(NEN_OPTIONS *pluginOptions, MCONTACT hContact, HANDLE hEve
pud.PluginData = pdata;
if (hContact)
- mir_sntprintf(pud.lptzContactName, MAX_CONTACTNAME, _T("%s"), pcli->pfnGetContactDisplayName(hContact, 0));
+ _tcsncpy_s(pud.lptzContactName, pcli->pfnGetContactDisplayName(hContact, 0), _TRUNCATE);
else
_tcsncpy_s(pud.lptzContactName, _A2T(dbe.szModule), _TRUNCATE);
TCHAR *szPreview = GetPreviewT((WORD)eventType, &dbe);
if (szPreview) {
- mir_sntprintf(pud.lptzText, MAX_SECONDLINE, _T("%s"), szPreview);
+ _tcsncpy_s(pud.lptzText, szPreview, _TRUNCATE);
mir_free(szPreview);
}
else _tcsncpy(pud.lptzText, _T(" "), MAX_SECONDLINE);
diff --git a/plugins/TabSRMM/src/generic_msghandlers.cpp b/plugins/TabSRMM/src/generic_msghandlers.cpp
index 698704de1b..61c2429ce2 100644
--- a/plugins/TabSRMM/src/generic_msghandlers.cpp
+++ b/plugins/TabSRMM/src/generic_msghandlers.cpp
@@ -1771,9 +1771,9 @@ void TSAPI DM_UpdateTitle(TWindowData *dat, WPARAM wParam, LPARAM lParam)
if (PluginConfig.m_StatusOnTabs)
mir_sntprintf(newtitle, 127, _T("%s (%s)"), newcontactname, dat->szStatus);
else
- mir_sntprintf(newtitle, 127, _T("%s"), newcontactname);
- }
- else mir_sntprintf(newtitle, 127, _T("%s"), _T("Forward"));
+ _tcsncpy_s(newtitle, newcontactname, _TRUNCATE);
+ } else
+ _tcsncpy_s(newtitle, _T("Forward"), _TRUNCATE);
item.mask |= TCIF_TEXT;
}
diff --git a/plugins/TabSRMM/src/infopanel.cpp b/plugins/TabSRMM/src/infopanel.cpp
index 9c7e6aed81..0922b715de 100644
--- a/plugins/TabSRMM/src/infopanel.cpp
+++ b/plugins/TabSRMM/src/infopanel.cpp
@@ -660,8 +660,9 @@ void CInfoPanel::Chat_RenderIPNickname(const HDC hdc, RECT& rcItem)
TCHAR *pTmp = _tcschr(si->ptszStatusbarText, ']');
pTmp += 2;
TCHAR tszTemp[30];
- if (si->ptszStatusbarText[0] == '[' && pTmp > si->ptszStatusbarText && ((pTmp - si->ptszStatusbarText) < (size_t)30)) {
- mir_sntprintf(tszTemp, pTmp - si->ptszStatusbarText, _T("%s"), si->ptszStatusbarText);
+ if (si->ptszStatusbarText[0] == '[' && pTmp > si->ptszStatusbarText && ((pTmp - si->ptszStatusbarText) < SIZEOF(tszTemp))) {
+ memcpy(tszTemp, si->ptszStatusbarText, ((pTmp - si->ptszStatusbarText) * sizeof(TCHAR)));
+ tszTemp[(pTmp - si->ptszStatusbarText)] = 0;
CSkin::RenderText(hdc, m_dat->hThemeIP, tszTemp, &rcItem, DT_SINGLELINE | DT_END_ELLIPSIS | DT_NOPREFIX | DT_VCENTER,
CSkin::m_glowSize, m_ipConfig.clrs[IPFONTID_STATUS]);
}
diff --git a/plugins/TabSRMM/src/mim.cpp b/plugins/TabSRMM/src/mim.cpp
index 90ee544ba8..8cdd44efa3 100644
--- a/plugins/TabSRMM/src/mim.cpp
+++ b/plugins/TabSRMM/src/mim.cpp
@@ -101,21 +101,25 @@ void CMimAPI::configureCustomFolders()
INT_PTR CMimAPI::foldersPathChanged()
{
- TCHAR szTemp[MAX_PATH + 2] = {'\0'};
+ TCHAR szTemp[MAX_PATH + 2];
if (m_hDataPath) {
+ szTemp[0] = 0;
FoldersGetCustomPathT(m_hDataPath, szTemp, MAX_PATH, const_cast<TCHAR *>(getDataPath()));
- mir_sntprintf(m_szProfilePath, MAX_PATH, _T("%s"), szTemp);
+ _tcsncpy_s(m_szProfilePath, szTemp, _TRUNCATE);
+ szTemp[0] = 0;
FoldersGetCustomPathT(m_hSkinsPath, szTemp, MAX_PATH, const_cast<TCHAR *>(getSkinPath()));
- mir_sntprintf(m_szSkinsPath, MAX_PATH - 1, _T("%s"), szTemp);
+ _tcsncpy_s(m_szSkinsPath, (MAX_PATH - 1), szTemp, _TRUNCATE);
Utils::ensureTralingBackslash(m_szSkinsPath);
+ szTemp[0] = 0;
FoldersGetCustomPathT(m_hAvatarsPath, szTemp, MAX_PATH, const_cast<TCHAR *>(getSavedAvatarPath()));
- mir_sntprintf(m_szSavedAvatarsPath, MAX_PATH, _T("%s"), szTemp);
+ _tcsncpy_s(m_szSavedAvatarsPath, szTemp, _TRUNCATE);
+ szTemp[0] = 0;
FoldersGetCustomPathT(m_hChatLogsPath, szTemp, MAX_PATH, const_cast<TCHAR *>(getChatLogPath()));
- mir_sntprintf(m_szChatLogsPath, MAX_PATH, _T("%s"), szTemp);
+ _tcsncpy_s(m_szChatLogsPath, (MAX_PATH - 1), szTemp, _TRUNCATE);
Utils::ensureTralingBackslash(m_szChatLogsPath);
}
diff --git a/plugins/TabSRMM/src/msgdlgutils.cpp b/plugins/TabSRMM/src/msgdlgutils.cpp
index 1be3b96482..fe567a05fc 100644
--- a/plugins/TabSRMM/src/msgdlgutils.cpp
+++ b/plugins/TabSRMM/src/msgdlgutils.cpp
@@ -1098,7 +1098,7 @@ void TSAPI GetMYUIN(TWindowData *dat)
if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci)) {
switch (ci.type) {
case CNFT_ASCIIZ:
- mir_sntprintf(dat->myUin, SIZEOF(dat->myUin), _T("%s"), reinterpret_cast<TCHAR *>(ci.pszVal));
+ _tcsncpy_s(dat->myUin, ci.pszVal, _TRUNCATE);
mir_free((void*)ci.pszVal);
break;
case CNFT_DWORD:
@@ -1823,33 +1823,26 @@ void TSAPI GetMyNick(TWindowData *dat)
ci.dwFlag = CNF_TCHAR | CNF_NICK;
if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci)) {
- if (ci.type == CNFT_ASCIIZ) {
- if (mir_tstrlen(reinterpret_cast<TCHAR *>(ci.pszVal)) < 1 || !_tcscmp(reinterpret_cast<TCHAR *>(ci.pszVal),
- TranslateT("'(Unknown Contact)'"))) {
- mir_sntprintf(dat->szMyNickname, SIZEOF(dat->szMyNickname), _T("%s"), dat->myUin[0] ? dat->myUin : TranslateT("'(Unknown Contact)'"));
- if (ci.pszVal) {
- mir_free(ci.pszVal);
- ci.pszVal = NULL;
- }
- }
- else {
- _tcsncpy(dat->szMyNickname, reinterpret_cast<TCHAR *>(ci.pszVal), 110);
- dat->szMyNickname[109] = 0;
- if (ci.pszVal) {
- mir_free(ci.pszVal);
- ci.pszVal = NULL;
- }
+ switch (ci.type) {
+ case CNFT_ASCIIZ:
+ if (mir_tstrlen((TCHAR*)ci.pszVal) == 0 ||
+ !_tcscmp((TCHAR*)ci.pszVal, TranslateT("'(Unknown Contact)'"))) {
+ _tcsncpy_s(dat->szMyNickname, (dat->myUin[0] ? dat->myUin : TranslateT("'(Unknown Contact)'")), _TRUNCATE);
+ } else {
+ _tcsncpy_s(dat->szMyNickname, (TCHAR*)ci.pszVal, _TRUNCATE);
}
- }
- else if (ci.type == CNFT_DWORD)
+ break;
+ case CNFT_DWORD:
_ltot(ci.dVal, dat->szMyNickname, 10);
- else
- _tcsncpy(dat->szMyNickname, _T("<undef>"), 110); // that really should *never* happen
- }
- else
- _tcsncpy(dat->szMyNickname, _T("<undef>"), 110); // same here
- if (ci.pszVal)
+ break;
+ default:
+ _tcsncpy_s(dat->szMyNickname, _T("<undef>"), _TRUNCATE); // that really should *never* happen
+ break;
+ }
mir_free(ci.pszVal);
+ } else {
+ _tcsncpy_s(dat->szMyNickname, _T("<undef>"), _TRUNCATE); // same here
+ }
}
HICON TSAPI MY_GetContactIcon(const TWindowData *dat, LPCSTR szSetting)
diff --git a/plugins/TabSRMM/src/msgoptions.cpp b/plugins/TabSRMM/src/msgoptions.cpp
index dff328cb2c..dba48a37d0 100644
--- a/plugins/TabSRMM/src/msgoptions.cpp
+++ b/plugins/TabSRMM/src/msgoptions.cpp
@@ -128,7 +128,7 @@ static int TSAPI ScanSkinDir(const TCHAR* tszFolder, HWND hwndCombobox)
GetPrivateProfileString(_T("Global"), _T("Name"), _T("None"), szBuf, 500, tszFinalName);
if (!_tcscmp(szBuf, _T("None"))) {
fd.cFileName[mir_tstrlen(fd.cFileName) - 4] = 0;
- mir_sntprintf(szBuf, 255, _T("%s"), fd.cFileName);
+ _tcsncpy_s(szBuf, fd.cFileName, _TRUNCATE);
}
PathToRelativeT(tszFinalName, tszRel, M.getSkinPath());
@@ -156,7 +156,7 @@ static int TSAPI RescanSkins(HWND hwndCombobox)
DBVARIANT dbv = { 0 };
TCHAR tszSkinRoot[MAX_PATH], tszFindMask[MAX_PATH];
- mir_sntprintf(tszSkinRoot, MAX_PATH, _T("%s"), M.getSkinPath());
+ _tcsncpy_s(tszSkinRoot, M.getSkinPath(), _TRUNCATE);
SetDlgItemText(GetParent(hwndCombobox), IDC_SKINROOTFOLDER, tszSkinRoot);
mir_sntprintf(tszFindMask, MAX_PATH, _T("%s*.*"), tszSkinRoot);
diff --git a/plugins/TabSRMM/src/sendlater.cpp b/plugins/TabSRMM/src/sendlater.cpp
index 57554d9e8a..fc800e8194 100644
--- a/plugins/TabSRMM/src/sendlater.cpp
+++ b/plugins/TabSRMM/src/sendlater.cpp
@@ -127,7 +127,7 @@ CSendLaterJob::~CSendLaterJob()
POPUPDATAT ppd = {0};
ppd.lchContact = hContact;
- mir_sntprintf(ppd.lptzContactName, MAX_CONTACTNAME, _T("%s"), tszName ? tszName : TranslateT("'(Unknown Contact)'"));
+ _tcsncpy_s(ppd.lptzContactName, (tszName ? tszName : TranslateT("'(Unknown Contact)'")), _TRUNCATE);
TCHAR *msgPreview = Utils::GetPreviewWithEllipsis(reinterpret_cast<TCHAR *>(&pBuf[mir_strlen((char *)pBuf) + 1]), 100);
if (fSuccess) {
mir_sntprintf(ppd.lptzText, MAX_SECONDLINE, TranslateT("A send later job completed successfully.\nThe original message: %s"),
@@ -603,7 +603,7 @@ void CSendLater::qMgrFillList(bool fClear)
::SendMessage(m_hwndList, LVM_SETITEM, 0, LPARAM(&lvItem));
if (p->lastSent == 0)
- mir_sntprintf(tszTimestamp, 30, _T("%s"), _T("Never"));
+ _tcsncpy_s(tszTimestamp, _T("Never"), _TRUNCATE);
else {
_tcsftime(tszTimestamp, 30, formatTime, _localtime32((__time32_t *)&p->lastSent));
tszTimestamp[29] = 0;
diff --git a/plugins/TabSRMM/src/sendqueue.cpp b/plugins/TabSRMM/src/sendqueue.cpp
index 310d7717af..6cc6dd33e4 100644
--- a/plugins/TabSRMM/src/sendqueue.cpp
+++ b/plugins/TabSRMM/src/sendqueue.cpp
@@ -52,7 +52,7 @@ void SendQueue::handleError(TWindowData *dat, const int iEntry) const
TCHAR szErrorMsg[500];
dat->iCurrentQueueError = iEntry;
- mir_sntprintf(szErrorMsg, 500, _T("%s"), m_jobs[iEntry].szErrorMsg);
+ _tcsncpy_s(szErrorMsg, m_jobs[iEntry].szErrorMsg, _TRUNCATE);
logError(dat, iEntry, szErrorMsg);
recallFailed(dat, iEntry);
showErrorControls(dat, TRUE);
diff --git a/plugins/TabSRMM/src/sidebar.cpp b/plugins/TabSRMM/src/sidebar.cpp
index 572292194b..9c42674cf6 100644
--- a/plugins/TabSRMM/src/sidebar.cpp
+++ b/plugins/TabSRMM/src/sidebar.cpp
@@ -146,7 +146,7 @@ const SIZE& CSideBarButton::measureItem()
HFONT oldFont = reinterpret_cast<HFONT>(::SelectObject(dc, ::GetStockObject(DEFAULT_GUI_FONT)));
- mir_sntprintf(tszLabel, 255, _T("%s"), m_dat->newtitle);
+ _tcsncpy_s(tszLabel, m_dat->newtitle, _TRUNCATE);
::GetTextExtentPoint32(dc, tszLabel, (int)mir_tstrlen(tszLabel), &sz);
sz.cx += 28;
diff --git a/plugins/TabSRMM/src/templates.cpp b/plugins/TabSRMM/src/templates.cpp
index fe20910d98..34595e958e 100644
--- a/plugins/TabSRMM/src/templates.cpp
+++ b/plugins/TabSRMM/src/templates.cpp
@@ -86,7 +86,7 @@ static void LoadTemplatesFrom(TTemplateSet *tSet, MCONTACT hContact, int rtl)
if (db_get_ts(hContact, rtl ? RTLTEMPLATES_MODULE : TEMPLATES_MODULE, TemplateNames[i], &dbv))
continue;
if (dbv.type == DBVT_ASCIIZ || dbv.type == DBVT_WCHAR)
- mir_sntprintf(tSet->szTemplates[i], TEMPLATE_LENGTH, _T("%s"), dbv.ptszVal);
+ _tcsncpy_s(tSet->szTemplates[i], dbv.ptszVal, _TRUNCATE);
db_free(&dbv);
}
}
diff --git a/plugins/TabSRMM/src/themeio.cpp b/plugins/TabSRMM/src/themeio.cpp
index de900af22d..35b2c36e2d 100644
--- a/plugins/TabSRMM/src/themeio.cpp
+++ b/plugins/TabSRMM/src/themeio.cpp
@@ -400,9 +400,9 @@ void TSAPI ReadThemeFromINI(const TCHAR *szIniFilenameT, TContainerData *dat, in
db_set_utf(NULL, TEMPLATES_MODULE, TemplateNames[i], szTemplateBuffer);
decoded = mir_utf8decodeW(szTemplateBuffer);
if (dat == 0)
- mir_sntprintf(LTR_Active.szTemplates[i], TEMPLATE_LENGTH, L"%s", decoded);
+ _tcsncpy_s(LTR_Active.szTemplates[i], decoded, _TRUNCATE);
else
- mir_sntprintf(dat->ltr_templates->szTemplates[i], TEMPLATE_LENGTH, L"%s", decoded);
+ _tcsncpy_s(dat->ltr_templates->szTemplates[i], decoded, _TRUNCATE);
mir_free(decoded);
}
@@ -413,9 +413,9 @@ void TSAPI ReadThemeFromINI(const TCHAR *szIniFilenameT, TContainerData *dat, in
db_set_utf(NULL, RTLTEMPLATES_MODULE, TemplateNames[i], szTemplateBuffer);
decoded = mir_utf8decodeW(szTemplateBuffer);
if (dat == 0)
- mir_sntprintf(RTL_Active.szTemplates[i], TEMPLATE_LENGTH, L"%s", decoded);
+ _tcsncpy_s(RTL_Active.szTemplates[i], decoded, _TRUNCATE);
else
- mir_sntprintf(dat->rtl_templates->szTemplates[i], TEMPLATE_LENGTH, L"%s", decoded);
+ _tcsncpy_s(dat->rtl_templates->szTemplates[i], decoded, _TRUNCATE);
mir_free(decoded);
}
}
@@ -435,7 +435,7 @@ const TCHAR* TSAPI GetThemeFileName(int iMode)
OPENFILENAME ofn = {0};
TCHAR szInitialDir[MAX_PATH];
- mir_sntprintf(szInitialDir, MAX_PATH, _T("%s"), M.getSkinPath());
+ _tcsncpy_s(szInitialDir, M.getSkinPath(), _TRUNCATE);
szFilename[0] = 0;
diff --git a/plugins/TabSRMM/src/themes.cpp b/plugins/TabSRMM/src/themes.cpp
index 48877e878e..e7cde034cd 100644
--- a/plugins/TabSRMM/src/themes.cpp
+++ b/plugins/TabSRMM/src/themes.cpp
@@ -2441,7 +2441,7 @@ void CSkin::setAeroEffect(LRESULT effect)
void CSkin::extractSkinsAndLogo(bool fForceOverwrite) const
{
TCHAR tszBasePath[MAX_PATH];
- mir_sntprintf(tszBasePath, MAX_PATH, _T("%s"), M.getDataPath());
+ _tcsncpy_s(tszBasePath, M.getDataPath(), _TRUNCATE);
if (tszBasePath[mir_tstrlen(tszBasePath) - 1] != '\\')
_tcscat(tszBasePath, _T("\\"));
diff --git a/plugins/TabSRMM/src/trayicon.cpp b/plugins/TabSRMM/src/trayicon.cpp
index 0e792c6617..5a75484758 100644
--- a/plugins/TabSRMM/src/trayicon.cpp
+++ b/plugins/TabSRMM/src/trayicon.cpp
@@ -141,7 +141,7 @@ void TSAPI CreateSystrayIcon(int create)
nim.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
nim.hIcon = PluginConfig.g_iconContainer;
nim.uCallbackMessage = DM_TRAYICONNOTIFY;
- mir_sntprintf(nim.szTip, 64, _T("%s"), _T("tabSRMM"));
+ _tcsncpy_s(nim.szTip, _T("tabSRMM"), _TRUNCATE);
if (create && !nen_options.bTrayExist) {
Shell_NotifyIcon(NIM_ADD, &nim);
nen_options.bTrayExist = TRUE;
@@ -230,11 +230,9 @@ void TSAPI AddContactToFavorites(MCONTACT hContact, const TCHAR *szNickname, con
TCHAR szFinalNick[100];
if (szNickname == NULL)
- mir_sntprintf(szFinalNick, SIZEOF(szFinalNick), _T("%s"), pcli->pfnGetContactDisplayName(hContact, 0));
- else {
- _tcsncpy(szFinalNick, szNickname, 100);
- szFinalNick[99] = 0;
- }
+ _tcsncpy_s(szFinalNick, pcli->pfnGetContactDisplayName(hContact, 0), _TRUNCATE);
+ else
+ _tcsncpy_s(szFinalNick, szNickname, _TRUNCATE);
if (szProto == NULL)
szProto = GetContactProto(hContact);
diff --git a/plugins/TabSRMM/src/utils.cpp b/plugins/TabSRMM/src/utils.cpp
index fb7541e440..6fe641661b 100644
--- a/plugins/TabSRMM/src/utils.cpp
+++ b/plugins/TabSRMM/src/utils.cpp
@@ -487,8 +487,8 @@ TCHAR* Utils::GetPreviewWithEllipsis(TCHAR *szText, size_t iMaxLen)
*p = 0;
uRequired = (p - szText) + 6;
}
- TCHAR *szResult = reinterpret_cast<TCHAR *>(mir_alloc(uRequired * sizeof(TCHAR)));
- mir_sntprintf(szResult, uRequired, fEllipsis ? _T("%s...") : _T("%s"), szText);
+ TCHAR *szResult = reinterpret_cast<TCHAR *>(mir_alloc((uRequired + 1) * sizeof(TCHAR)));
+ mir_sntprintf(szResult, (uRequired + 1), fEllipsis ? _T("%s...") : _T("%s"), szText);
if (p)
*p = cSaved;
diff --git a/plugins/Utils/mir_options.cpp b/plugins/Utils/mir_options.cpp
index 7d7e9fdbc3..ea8844b93b 100644
--- a/plugins/Utils/mir_options.cpp
+++ b/plugins/Utils/mir_options.cpp
@@ -76,10 +76,9 @@ static void PathToRelative(TCHAR *pOut, size_t outSize, const TCHAR *pSrc)
}
size_t len = mir_tstrlen(dbPath);
- if (_tcsnicmp(pSrc, dbPath, len))
- mir_sntprintf(pOut, outSize, _T("%s"), pSrc + len);
- else
- mir_tstrncpy(pOut, pSrc, (int)outSize);
+ if (!_tcsnicmp(pSrc, dbPath, len))
+ len = 0;
+ _tcsncpy_s(pOut, outSize, (pSrc + len), _TRUNCATE);
}
}
diff --git a/plugins/Weather/src/weather_conv.cpp b/plugins/Weather/src/weather_conv.cpp
index c375c9d95f..4a0a734392 100644
--- a/plugins/Weather/src/weather_conv.cpp
+++ b/plugins/Weather/src/weather_conv.cpp
@@ -109,7 +109,7 @@ void GetTemp(TCHAR *tempchar, TCHAR *unit, TCHAR* str)
// rounding
numToStr((temp-32)/9*5, tstr, SIZEOF(tstr));
if (opt.DoNotAppendUnit)
- mir_sntprintf(str, MAX_DATA_LEN, _T("%s"), tstr);
+ _tcsncpy_s(str, MAX_DATA_LEN, tstr, _TRUNCATE);
else
mir_sntprintf(str, MAX_DATA_LEN, _T("%s%sC"), tstr, opt.DegreeSign);
break;
@@ -117,7 +117,7 @@ void GetTemp(TCHAR *tempchar, TCHAR *unit, TCHAR* str)
case 2:
numToStr(temp, tstr, SIZEOF(tstr));
if (opt.DoNotAppendUnit)
- mir_sntprintf(str, MAX_DATA_LEN, _T("%s"), tstr);
+ _tcsncpy_s(str, MAX_DATA_LEN, tstr, _TRUNCATE);
else
mir_sntprintf(str, MAX_DATA_LEN, _T("%s%sF"), tstr, opt.DegreeSign);
break;
@@ -394,8 +394,8 @@ WORD GetIcon(const TCHAR* cond, WIDATA *Data)
j++;
// using the format _T("# Weather <condition name> <counter> #"
mir_sntprintf(LangPackStr, SIZEOF(LangPackStr), _T("# Weather %s %i #"), statusStr[i], j);
- mir_sntprintf(LangPackStr1, SIZEOF(LangPackStr1), _T("%s"), TranslateTS(LangPackStr));
- CharLowerBuff(LangPackStr1, (DWORD)_tcslen(LangPackStr1));
+ _tcsncpy_s(LangPackStr1, TranslateTS(LangPackStr), _TRUNCATE);
+ CharLowerBuff(LangPackStr1, _tcslen(LangPackStr1));
if (_tcsstr(cond, LangPackStr1) != NULL)
return statusValue[i];
// loop until the translation string exists (ie, the translated string is differ from original)
diff --git a/plugins/YAMN/src/browser/mailbrowser.cpp b/plugins/YAMN/src/browser/mailbrowser.cpp
index 125365ec54..6b0cd74b25 100644
--- a/plugins/YAMN/src/browser/mailbrowser.cpp
+++ b/plugins/YAMN/src/browser/mailbrowser.cpp
@@ -1479,14 +1479,14 @@ INT_PTR CALLBACK DlgProcYAMNShowMessage(HWND hDlg,UINT msg,WPARAM wParam,LPARAM
WCHAR *title=0;
size_t size = (From ? wcslen(From) : 0) + (Subj ? wcslen(Subj) : 0) + 4;
title = new WCHAR[size];
- if (From&&Subj)
+ if (From && Subj)
mir_sntprintf(title, size, L"%s (%s)", Subj, From);
else if (From)
- mir_sntprintf(title, size, L"%s", From);
+ _tcsncpy_s(title, size, From, _TRUNCATE);
else if (Subj)
- mir_sntprintf(title, size, L"%s", Subj);
+ _tcsncpy_s(title, size, Subj, _TRUNCATE);
else
- mir_sntprintf(title, size, L"none");
+ _tcsncpy_s(title, size, L"none", _TRUNCATE);
if (Subj) delete[] Subj;
if (From) delete[] From;
SendMessageW(hDlg,WM_SETTEXT,0,(LPARAM)title);
diff --git a/protocols/AimOscar/src/popup.cpp b/protocols/AimOscar/src/popup.cpp
index 107908da51..c561994451 100644
--- a/protocols/AimOscar/src/popup.cpp
+++ b/protocols/AimOscar/src/popup.cpp
@@ -80,7 +80,7 @@ void CAimProto::ShowPopup(const char* msg, int flags, char* url)
}
TCHAR *msgt = (flags & TCHAR_POPUP) ? mir_tstrdup((TCHAR*)msg) : mir_a2t(msg);
- mir_sntprintf(ppd.lptzText, SIZEOF(ppd.lptzText), _T("%s"), TranslateTS(msgt));
+ _tcsncpy_s(ppd.lptzText, TranslateTS(msgt), _TRUNCATE);
mir_free(msgt);
if (!ServiceExists(MS_POPUP_ADDPOPUPT))
diff --git a/protocols/FacebookRM/src/proto.cpp b/protocols/FacebookRM/src/proto.cpp
index a5443be932..8d76eb94f7 100644
--- a/protocols/FacebookRM/src/proto.cpp
+++ b/protocols/FacebookRM/src/proto.cpp
@@ -427,7 +427,7 @@ int FacebookProto::OnEvent(PROTOEVENTTYPE event, WPARAM wParam, LPARAM lParam)
INT_PTR FacebookProto::SvcCreateAccMgrUI(WPARAM wParam, LPARAM lParam)
{
- return (int)CreateDialogParam(g_hInstance,MAKEINTRESOURCE(IDD_FACEBOOKACCOUNT),
+ return (INT_PTR)CreateDialogParam(g_hInstance,MAKEINTRESOURCE(IDD_FACEBOOKACCOUNT),
(HWND)lParam, FBAccountProc, (LPARAM)this);
}
diff --git a/protocols/Gadu-Gadu/src/image.cpp b/protocols/Gadu-Gadu/src/image.cpp
index 213e24b51e..fd7ef6e2ab 100644
--- a/protocols/Gadu-Gadu/src/image.cpp
+++ b/protocols/Gadu-Gadu/src/image.cpp
@@ -836,7 +836,7 @@ int GGPROTO::img_displayasmsg(MCONTACT hContact, void *img)
mir_sntprintf(szPath + tPathLen, MAX_PATH - tPathLen, _T("\\%s"), dat->lpszFileName);
if ((pImgext = gg_img_hasextension(szPath)) == NULL)
pImgext = szPath + _tcslen(szPath);
- mir_sntprintf(imgext, SIZEOF(imgext), _T("%s"), pImgext);
+ _tcsncpy_s(imgext, pImgext, _TRUNCATE);
for (i = 1; ; ++i)
{
if ((res = gg_img_isexists(szPath, dat)) != -1) break;
diff --git a/protocols/IRCG/src/options.cpp b/protocols/IRCG/src/options.cpp
index 85097b5146..5fa543c8d1 100644
--- a/protocols/IRCG/src/options.cpp
+++ b/protocols/IRCG/src/options.cpp
@@ -712,7 +712,7 @@ void CConnectPrefsDlg::OnApply()
m_nick.GetText(m_proto->m_nick, SIZEOF(m_proto->m_nick));
removeSpaces(m_proto->m_nick);
- mir_sntprintf(m_proto->m_pNick, SIZEOF(m_proto->m_pNick), _T("%s"), m_proto->m_nick);
+ _tcsncpy_s(m_proto->m_pNick, m_proto->m_nick, _TRUNCATE);
m_nick2.GetText(m_proto->m_alternativeNick, SIZEOF(m_proto->m_alternativeNick));
removeSpaces(m_proto->m_alternativeNick);
m_userID.GetText(m_proto->m_userID, SIZEOF(m_proto->m_userID));
@@ -1815,7 +1815,7 @@ struct CDlgAccMgrUI : public CProtoDlgBase<CIrcProto>
m_nick.GetText(m_proto->m_nick, SIZEOF(m_proto->m_nick));
removeSpaces(m_proto->m_nick);
- mir_sntprintf(m_proto->m_pNick, 30, _T("%s"), m_proto->m_nick);
+ _tcsncpy_s(m_proto->m_pNick, m_proto->m_nick, _TRUNCATE);
m_nick2.GetText(m_proto->m_alternativeNick, SIZEOF(m_proto->m_alternativeNick));
removeSpaces(m_proto->m_alternativeNick);
m_userID.GetText(m_proto->m_userID, SIZEOF(m_proto->m_userID));
diff --git a/protocols/JabberG/src/jabber_chat.cpp b/protocols/JabberG/src/jabber_chat.cpp
index 4692566bef..529d78dbfb 100644
--- a/protocols/JabberG/src/jabber_chat.cpp
+++ b/protocols/JabberG/src/jabber_chat.cpp
@@ -1202,8 +1202,9 @@ static void sttNickListHook(CJabberProto *ppro, JABBER_LIST_ITEM *item, GCHOOK*
MCONTACT hContact;
JABBER_SEARCH_RESULT jsr = { 0 };
jsr.hdr.cbSize = sizeof(JABBER_SEARCH_RESULT);
- mir_sntprintf(jsr.jid, SIZEOF(jsr.jid), _T("%s"), him->m_tszRealJid);
- if (TCHAR *tmp = _tcschr(jsr.jid, _T('/'))) *tmp = 0;
+ _tcsncpy_s(jsr.jid, him->m_tszRealJid, _TRUNCATE);
+ if (TCHAR *tmp = _tcschr(jsr.jid, _T('/')))
+ *tmp = 0;
JABBER_LIST_ITEM *item = ppro->ListAdd(LIST_VCARD_TEMP, jsr.jid);
ppro->ListAddResource(LIST_VCARD_TEMP, jsr.jid, him->m_iStatus, him->m_tszStatusMessage, him->m_iPriority);
@@ -1218,8 +1219,9 @@ static void sttNickListHook(CJabberProto *ppro, JABBER_LIST_ITEM *item, GCHOOK*
JABBER_SEARCH_RESULT jsr = { 0 };
jsr.hdr.cbSize = sizeof(JABBER_SEARCH_RESULT);
jsr.hdr.flags = PSR_TCHAR;
- mir_sntprintf(jsr.jid, SIZEOF(jsr.jid), _T("%s"), him->m_tszRealJid);
- if (TCHAR *tmp = _tcschr(jsr.jid, _T('/'))) *tmp = 0;
+ _tcsncpy_s(jsr.jid, him->m_tszRealJid, _TRUNCATE);
+ if (TCHAR *tmp = _tcschr(jsr.jid, _T('/')))
+ *tmp = 0;
jsr.hdr.nick = jsr.jid;
ADDCONTACTSTRUCT acs = { 0 };
diff --git a/protocols/JabberG/src/jabber_disco.cpp b/protocols/JabberG/src/jabber_disco.cpp
index 66b60174bc..4c21802990 100644
--- a/protocols/JabberG/src/jabber_disco.cpp
+++ b/protocols/JabberG/src/jabber_disco.cpp
@@ -1412,7 +1412,7 @@ void CJabberProto::ServiceDiscoveryShowMenu(CJabberSDNode *pNode, HTREELISTITEM
MCONTACT hContact = HContactFromJID(pNode->GetJid());
if (!hContact) {
JABBER_SEARCH_RESULT jsr={0};
- mir_sntprintf(jsr.jid, SIZEOF(jsr.jid), _T("%s"), jid);
+ _tcsncpy_s(jsr.jid, jid, _TRUNCATE);
jsr.hdr.cbSize = sizeof(JABBER_SEARCH_RESULT);
hContact = (MCONTACT)CallProtoService(m_szModuleName, PS_ADDTOLIST, PALF_TEMPORARY, (LPARAM)&jsr);
}
diff --git a/protocols/JabberG/src/jabber_rc.cpp b/protocols/JabberG/src/jabber_rc.cpp
index 2ce34e50d0..9267f68a48 100644
--- a/protocols/JabberG/src/jabber_rc.cpp
+++ b/protocols/JabberG/src/jabber_rc.cpp
@@ -584,8 +584,8 @@ int CJabberProto::AdhocForwardHandler(HXML, CJabberIqInfo *pInfo, CJabberAdhocSe
if (cbBlob < dbei.cbBlob) { // rest of message contains a sender's resource
ptrT szOResource( mir_utf8decodeT((LPSTR)dbei.pBlob + cbBlob+1));
mir_sntprintf(szOFrom, SIZEOF(szOFrom), _T("%s/%s"), tszJid, szOResource);
- }
- else mir_sntprintf(szOFrom, SIZEOF(szOFrom), _T("%s"), tszJid);
+ } else
+ _tcsncpy_s(szOFrom, tszJid, _TRUNCATE);
addressesNode << XCHILD(_T("address")) << XATTR(_T("type"), _T("ofrom")) << XATTR(_T("jid"), szOFrom);
addressesNode << XCHILD(_T("address")) << XATTR(_T("type"), _T("oto")) << XATTR(_T("jid"), m_ThreadInfo->fullJID);
diff --git a/protocols/JabberG/src/jabber_svc.cpp b/protocols/JabberG/src/jabber_svc.cpp
index f35fcbda5b..e4176528e4 100644
--- a/protocols/JabberG/src/jabber_svc.cpp
+++ b/protocols/JabberG/src/jabber_svc.cpp
@@ -536,7 +536,7 @@ INT_PTR __cdecl CJabberProto::JabberSendNudge(WPARAM hContact, LPARAM)
if (szResource)
mir_sntprintf(tszJid, SIZEOF(tszJid), _T("%s/%s"), jid, szResource);
else
- mir_sntprintf(tszJid, SIZEOF(tszJid), _T("%s"), jid);
+ _tcsncpy_s(tszJid, jid, _TRUNCATE);
JabberCapsBits jcb = GetResourceCapabilites(tszJid, FALSE);
m_ThreadInfo->send(
diff --git a/protocols/JabberG/src/jabber_userinfo.cpp b/protocols/JabberG/src/jabber_userinfo.cpp
index a6a550ea7f..21a511149b 100644
--- a/protocols/JabberG/src/jabber_userinfo.cpp
+++ b/protocols/JabberG/src/jabber_userinfo.cpp
@@ -281,7 +281,7 @@ static void sttFillResourceInfo(CJabberProto *ppro, HWND hwndTree, HTREEITEM hti
if (g_JabberFeatCapPairs[i].tszDescription)
mir_sntprintf(szDescription, SIZEOF(szDescription), _T("%s (%s)"), TranslateTS(g_JabberFeatCapPairs[i].tszDescription), g_JabberFeatCapPairs[i].szFeature);
else
- mir_sntprintf(szDescription, SIZEOF(szDescription), _T("%s"), g_JabberFeatCapPairs[i].szFeature);
+ _tcsncpy_s(szDescription, g_JabberFeatCapPairs[i].szFeature, _TRUNCATE);
sttFillInfoLine(hwndTree, htiCaps, NULL, NULL, szDescription, sttInfoLineId(resource, INFOLINE_CAPS, i));
}
@@ -291,7 +291,7 @@ static void sttFillResourceInfo(CJabberProto *ppro, HWND hwndTree, HTREEITEM hti
if (ppro->m_lstJabberFeatCapPairsDynamic[j]->szDescription)
mir_sntprintf(szDescription, SIZEOF(szDescription), _T("%s (%s)"), TranslateTS(ppro->m_lstJabberFeatCapPairsDynamic[j]->szDescription), ppro->m_lstJabberFeatCapPairsDynamic[j]->szFeature);
else
- mir_sntprintf(szDescription, SIZEOF(szDescription), _T("%s"), ppro->m_lstJabberFeatCapPairsDynamic[j]->szFeature);
+ _tcsncpy_s(szDescription, ppro->m_lstJabberFeatCapPairsDynamic[j]->szFeature, _TRUNCATE);
sttFillInfoLine(hwndTree, htiCaps, NULL, NULL, szDescription, sttInfoLineId(resource, INFOLINE_CAPS, i));
}
}
@@ -322,7 +322,7 @@ static void sttFillAdvStatusInfo(CJabberProto *ppro, HWND hwndTree, HTREEITEM ht
if (szAdvStatusText && *szAdvStatusText)
mir_sntprintf(szText, 2047, _T("%s (%s)"), TranslateTS(szAdvStatusTitle), szAdvStatusText);
else
- mir_sntprintf(szText, 2047, _T("%s"), TranslateTS(szAdvStatusTitle));
+ _tcsncpy_s(szText, TranslateTS(szAdvStatusTitle), _TRUNCATE);
sttFillInfoLine(hwndTree, htiRoot, Skin_GetIcon(szAdvStatusIcon), szTitle, szText, dwInfoLine);
}
diff --git a/protocols/MRA/src/Mra_functions.cpp b/protocols/MRA/src/Mra_functions.cpp
index 1db43cfae1..a0244d2a66 100644
--- a/protocols/MRA/src/Mra_functions.cpp
+++ b/protocols/MRA/src/Mra_functions.cpp
@@ -872,7 +872,7 @@ void CMraProto::ShowFormattedErrorMessage(LPWSTR lpwszErrText, DWORD dwErrorCode
size_t dwErrDescriptionSize;
if (dwErrorCode == NO_ERROR)
- mir_sntprintf(szErrorText, SIZEOF(szErrorText), _T("%s"), TranslateTS(lpwszErrText));
+ _tcsncpy_s(szErrorText, TranslateTS(lpwszErrText), _TRUNCATE);
else {
dwErrDescriptionSize = (FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwErrorCode, 0, szErrDescription, (SIZEOF(szErrDescription) - sizeof(WCHAR)), NULL) - 2);
szErrDescription[dwErrDescriptionSize] = 0;
diff --git a/protocols/Sametime/src/files.cpp b/protocols/Sametime/src/files.cpp
index 29f3a0a077..f890a3f19e 100644
--- a/protocols/Sametime/src/files.cpp
+++ b/protocols/Sametime/src/files.cpp
@@ -35,8 +35,8 @@ void mwFileTransfer_offered(mwFileTransfer* ft) {
TCHAR* messageT = mir_utf8decodeT(message);
mir_sntprintf(descriptionT, SIZEOF(descriptionT), _T("%s - %s"), filenameT, messageT);
mir_free(messageT);
- }
- else mir_sntprintf(descriptionT, SIZEOF(descriptionT), _T("%s"), filenameT);
+ } else
+ _tcsncpy_s(descriptionT, filenameT, _TRUNCATE);
PROTORECVFILET pre = {0};
pre.flags = PREF_TCHAR;
diff --git a/protocols/Twitter/src/proto.cpp b/protocols/Twitter/src/proto.cpp
index b2e333978f..f00c08e7af 100644
--- a/protocols/Twitter/src/proto.cpp
+++ b/protocols/Twitter/src/proto.cpp
@@ -223,7 +223,7 @@ int TwitterProto::OnEvent(PROTOEVENTTYPE event,WPARAM wParam,LPARAM lParam)
INT_PTR TwitterProto::SvcCreateAccMgrUI(WPARAM,LPARAM lParam)
{
- return (int)CreateDialogParam(g_hInstance,MAKEINTRESOURCE(IDD_TWITTERACCOUNT),(HWND)lParam, first_run_dialog, (LPARAM)this );
+ return (INT_PTR)CreateDialogParam(g_hInstance,MAKEINTRESOURCE(IDD_TWITTERACCOUNT),(HWND)lParam, first_run_dialog, (LPARAM)this );
}
INT_PTR TwitterProto::GetName(WPARAM wParam,LPARAM lParam)
diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp
index 2bf4fc1aa8..d2201f680f 100644
--- a/protocols/VKontakte/src/misc.cpp
+++ b/protocols/VKontakte/src/misc.cpp
@@ -538,10 +538,12 @@ void CVkProto::SetMirVer(MCONTACT hContact, int platform)
bool tlstrstr(TCHAR* _s1, TCHAR* _s2)
{
TCHAR s1[1024], s2[1024];
- mir_sntprintf(s1, SIZEOF(s1), _T("%s"), _s1);
- mir_sntprintf(s2, SIZEOF(s2), _T("%s"), _s2);
+
+ _tcsncpy_s(s1, _s1, _TRUNCATE);
CharLowerBuff(s1, SIZEOF(s1));
+ _tcsncpy_s(s2, _s2, _TRUNCATE);
CharLowerBuff(s2, SIZEOF(s2));
+
return _tcsstr(s1, s2) != NULL;
}
diff --git a/protocols/Yahoo/src/avatar.cpp b/protocols/Yahoo/src/avatar.cpp
index 7bff4a98e8..f698adb092 100644
--- a/protocols/Yahoo/src/avatar.cpp
+++ b/protocols/Yahoo/src/avatar.cpp
@@ -616,10 +616,10 @@ void CYahooProto::GetAvatarFileName(MCONTACT hContact, TCHAR* pszDest, int cbLen
if (hContact != NULL) {
int ck_sum = getDword(hContact, "PictCK", 0);
tPathLen += mir_sntprintf(pszDest + tPathLen, cbLen - tPathLen, _T("\\%lX"), ck_sum);
- }
- else tPathLen += mir_sntprintf(pszDest + tPathLen, cbLen - tPathLen, _T("\\%S avatar"), m_szModuleName);
+ } else
+ tPathLen += mir_sntprintf(pszDest + tPathLen, cbLen - tPathLen, _T("\\%S avatar"), m_szModuleName);
- mir_sntprintf(pszDest + tPathLen, cbLen - tPathLen, _T("%s"), type == 1 ? _T(".swf") : _T(".png"));
+ _tcsncpy_s((pszDest + tPathLen), (cbLen - tPathLen), (type == 1 ? _T(".swf") : _T(".png")), _TRUNCATE);
}
INT_PTR __cdecl CYahooProto::GetAvatarInfo(WPARAM wParam,LPARAM lParam)
diff --git a/src/core/stdauth/auth.cpp b/src/core/stdauth/auth.cpp
index f2cfaa041b..df3ea40221 100644
--- a/src/core/stdauth/auth.cpp
+++ b/src/core/stdauth/auth.cpp
@@ -75,7 +75,7 @@ static int AuthEventAdded(WPARAM, LPARAM lParam)
if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci)) {
switch (ci.type) {
case CNFT_ASCIIZ:
- mir_sntprintf(szUid, SIZEOF(szUid), _T("%s"), ci.pszVal);
+ _tcsncpy_s(szUid, ci.pszVal, _TRUNCATE);
mir_free(ci.pszVal);
break;
diff --git a/src/core/stdauth/authdialogs.cpp b/src/core/stdauth/authdialogs.cpp
index 99000a8663..fbbc377047 100644
--- a/src/core/stdauth/authdialogs.cpp
+++ b/src/core/stdauth/authdialogs.cpp
@@ -72,10 +72,10 @@ INT_PTR CALLBACK DlgProcAdded(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar
if (off)
mir_sntprintf(name + off, SIZEOF(name) - off, _T(" (%s)"), nickT);
else
- mir_sntprintf(name, SIZEOF(name), _T("%s"), nickT);
+ _tcsncpy_s(name, nickT, _TRUNCATE);
}
if (!name[0])
- _tcscpy(name, TranslateT("<Unknown>"));
+ _tcsncpy_s(name, TranslateT("<Unknown>"), _TRUNCATE);
TCHAR hdr[256];
if (uin && emailT[0])
@@ -197,10 +197,10 @@ INT_PTR CALLBACK DlgProcAuthReq(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
if (off)
mir_sntprintf(name + off, SIZEOF(name) - off, _T(" (%s)"), (TCHAR*)nickT);
else
- mir_sntprintf(name, SIZEOF(name), _T("%s"), (TCHAR*)nickT);
+ _tcsncpy_s(name, nickT, _TRUNCATE);
}
if (!name[0])
- _tcscpy(name, TranslateT("<Unknown>"));
+ _tcsncpy_s(name, TranslateT("<Unknown>"), _TRUNCATE);
TCHAR hdr[256];
if (uin && emailT[0])
diff --git a/src/core/stdchat/src/window.cpp b/src/core/stdchat/src/window.cpp
index 2d9b797540..75be4f1bbc 100644
--- a/src/core/stdchat/src/window.cpp
+++ b/src/core/stdchat/src/window.cpp
@@ -2387,7 +2387,7 @@ LABEL_SHOWWINDOW:
MODULEINFO *pInfo = pci->MM_FindModule(si->pszModule);
if (pInfo) {
TCHAR szFile[MAX_PATH], szName[MAX_PATH], szFolder[MAX_PATH];
- mir_sntprintf(szName, MAX_PATH, _T("%s"), pInfo->ptszModDispName ? pInfo->ptszModDispName : _A2T(si->pszModule));
+ _tcsncpy_s(szName, (pInfo->ptszModDispName ? pInfo->ptszModDispName : _A2T(si->pszModule)), _TRUNCATE);
ValidateFilename(szName);
mir_sntprintf(szFolder, MAX_PATH, _T("%s\\%s"), g_Settings.pszLogDir, szName);
diff --git a/src/core/stdfile/filexferdlg.cpp b/src/core/stdfile/filexferdlg.cpp
index 962283e9b0..3bf08dc08d 100644
--- a/src/core/stdfile/filexferdlg.cpp
+++ b/src/core/stdfile/filexferdlg.cpp
@@ -108,8 +108,8 @@ static void __cdecl RunVirusScannerThread(struct virusscanthreadstartinfo *info)
info->szFile[_tcslen(info->szFile) - 1] = '\0';
*pszReplace = 0;
mir_sntprintf(szCmdLine, SIZEOF(szCmdLine), _T("%s\"%s\"%s"), dbv.ptszVal, info->szFile, pszReplace + 2);
- }
- else mir_tstrncpy(szCmdLine, dbv.ptszVal, SIZEOF(szCmdLine));
+ } else
+ _tcsncpy_s(szCmdLine, dbv.ptszVal, _TRUNCATE);
PROCESS_INFORMATION pi;
if (CreateProcess(NULL, szCmdLine, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) {
diff --git a/src/core/stdmsg/src/msgdialog.cpp b/src/core/stdmsg/src/msgdialog.cpp
index d7e9870415..8bb5a9ce11 100644
--- a/src/core/stdmsg/src/msgdialog.cpp
+++ b/src/core/stdmsg/src/msgdialog.cpp
@@ -1002,7 +1002,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)& ci)) {
switch (ci.type) {
case CNFT_ASCIIZ:
- mir_sntprintf(buf, SIZEOF(buf), _T("%s"), ci.pszVal);
+ _tcsncpy_s(buf, ci.pszVal, _TRUNCATE);
mir_free(ci.pszVal);
break;
@@ -1113,7 +1113,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci)) {
switch (ci.type) {
case CNFT_ASCIIZ:
- mir_sntprintf(buf, SIZEOF(buf), _T("%s"), (TCHAR*)ci.pszVal);
+ _tcsncpy_s(buf, ci.pszVal, _TRUNCATE);
mir_free(ci.pszVal);
break;
case CNFT_DWORD:
diff --git a/src/modules/chat/log.cpp b/src/modules/chat/log.cpp
index 153e01e7cd..d2ebaefbe9 100644
--- a/src/modules/chat/log.cpp
+++ b/src/modules/chat/log.cpp
@@ -235,7 +235,7 @@ static void AddEventToBuffer(char **buffer, int *bufferEnd, int *bufferAlloced,
if (streamData->lin->ptszUserInfo)
mir_sntprintf(szTemp, SIZEOF(szTemp), _T("%s (%s)"), szTemp2, streamData->lin->ptszUserInfo);
else
- mir_sntprintf(szTemp, SIZEOF(szTemp), _T("%s"), szTemp2);
+ _tcsncpy_s(szTemp, szTemp2, _TRUNCATE);
pszNick = szTemp;
}
diff --git a/src/modules/chat/tools.cpp b/src/modules/chat/tools.cpp
index aabd4535fb..ee64919f10 100644
--- a/src/modules/chat/tools.cpp
+++ b/src/modules/chat/tools.cpp
@@ -489,7 +489,7 @@ BOOL LogToFile(SESSION_INFO *si, GCEVENT *gce)
if (gce->ptszUserInfo)
mir_sntprintf(szTemp, SIZEOF(szTemp), _T("%s (%s)"), szTemp2, gce->ptszUserInfo);
else
- mir_sntprintf(szTemp, SIZEOF(szTemp), _T("%s"), szTemp2);
+ _tcsncpy_s(szTemp, szTemp2, _TRUNCATE);
pszNick = szTemp;
}
@@ -546,7 +546,7 @@ BOOL LogToFile(SESSION_INFO *si, GCEVENT *gce)
break;
case GC_EVENT_INFORMATION:
p = '!';
- mir_sntprintf(szBuffer, SIZEOF(szBuffer), _T("%s"), ci.RemoveFormatting(gce->ptszText));
+ _tcsncpy_s(szBuffer, ci.RemoveFormatting(gce->ptszText), _TRUNCATE);
break;
case GC_EVENT_ADDSTATUS:
p = '+';
diff --git a/src/modules/clist/clistmod.cpp b/src/modules/clist/clistmod.cpp
index fc6c717519..df89fd1a23 100644
--- a/src/modules/clist/clistmod.cpp
+++ b/src/modules/clist/clistmod.cpp
@@ -119,7 +119,7 @@ static INT_PTR GetStatusModeDescription(WPARAM wParam, LPARAM lParam)
if (!(lParam & GSMDF_TCHAR)) {
static char szMode[64];
char *buf2 = mir_u2a(buf1);
- mir_snprintf(szMode, SIZEOF(szMode), "%s", buf2);
+ strncpy_s(szMode, buf2, _TRUNCATE);
mir_free(buf2);
return (INT_PTR)szMode;
}
diff --git a/src/modules/fonts/FontOptions.cpp b/src/modules/fonts/FontOptions.cpp
index 97598e7674..3091965994 100644
--- a/src/modules/fonts/FontOptions.cpp
+++ b/src/modules/fonts/FontOptions.cpp
@@ -522,7 +522,7 @@ static void sttSaveFontData(HWND hwndDlg, FontInternal &F)
if (F.flags & FIDF_APPENDNAME)
mir_snprintf(str, SIZEOF(str), "%sName", F.prefix);
else
- mir_snprintf(str, SIZEOF(str), "%s", F.prefix);
+ strncpy_s(str, F.prefix, _TRUNCATE);
if (db_set_ts(NULL, F.dbSettingsGroup, str, F.value.szFace)) {
char buff[1024];
@@ -1185,7 +1185,7 @@ static INT_PTR CALLBACK DlgProcLogOptions(HWND hwndDlg, UINT msg, WPARAM wParam,
for (i=0; i < colour_id_list_w2.getCount(); i++) {
ColourInternal& C = colour_id_list_w2[i];
- mir_snprintf(str, SIZEOF(str), "%s", C.setting);
+ strncpy_s(str, C.setting, _TRUNCATE);
db_set_dw(NULL, C.dbSettingsGroup, str, C.value);
}
diff --git a/src/modules/fonts/services.cpp b/src/modules/fonts/services.cpp
index 1c7b0783dd..63ab76242c 100644
--- a/src/modules/fonts/services.cpp
+++ b/src/modules/fonts/services.cpp
@@ -142,8 +142,10 @@ int GetFontSettingFromDB(char *settings_group, char *prefix, LOGFONT* lf, COLORR
GetDefaultFontSetting(lf, colour);
- if (flags & FIDF_APPENDNAME) mir_snprintf(idstr, SIZEOF(idstr), "%sName", prefix);
- else mir_snprintf(idstr, SIZEOF(idstr), "%s", prefix);
+ if (flags & FIDF_APPENDNAME)
+ mir_snprintf(idstr, SIZEOF(idstr), "%sName", prefix);
+ else
+ strncpy_s(idstr, prefix, _TRUNCATE);
if (!db_get_ts(NULL, settings_group, idstr, &dbv)) {
_tcscpy(lf->lfFaceName, dbv.ptszVal);
diff --git a/src/modules/netlib/netlibautoproxy.cpp b/src/modules/netlib/netlibautoproxy.cpp
index 5f3c1280de..356c25fc8c 100644
--- a/src/modules/netlib/netlibautoproxy.cpp
+++ b/src/modules/netlib/netlibautoproxy.cpp
@@ -176,7 +176,7 @@ bool NetlibGetIeProxyConn(NetlibConnection *nlc, bool forceHttps)
mir_snprintf(szUrl, SIZEOF(szUrl), "http://%s", nlc->nloc.szHost);
else
{
- mir_snprintf(szUrl, SIZEOF(szUrl), "%s", nlc->nloc.szHost);
+ strncpy_s(szUrl, nlc->nloc.szHost, _TRUNCATE);
noHttp = true;
}
diff --git a/src/modules/skin/sounds.cpp b/src/modules/skin/sounds.cpp
index 64a257620e..67a92df35a 100644
--- a/src/modules/skin/sounds.cpp
+++ b/src/modules/skin/sounds.cpp
@@ -298,7 +298,7 @@ INT_PTR CALLBACK DlgProcSoundOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
db_free(&dbv);
} } }
- mir_sntprintf(strFull, SIZEOF(strFull), _T("%s"), snd.ptszTempFile ? snd.ptszTempFile : _T(""));
+ _tcsncpy_s(strFull, (snd.ptszTempFile ? snd.ptszTempFile : _T("")), _TRUNCATE);
PathToAbsoluteT(strFull, strdir);
OPENFILENAME ofn;
diff --git a/src/modules/utils/bmpfilter.cpp b/src/modules/utils/bmpfilter.cpp
index 9e7c28caba..16b3963ab8 100644
--- a/src/modules/utils/bmpfilter.cpp
+++ b/src/modules/utils/bmpfilter.cpp
@@ -39,7 +39,7 @@ static INT_PTR sttBitmapLoader(const TCHAR* ptszFileName)
TCHAR szFilename[MAX_PATH];
if (!PathToAbsoluteT(ptszFileName, szFilename))
- mir_sntprintf(szFilename, SIZEOF(szFilename), _T("%s"), ptszFileName);
+ _tcsncpy_s(szFilename, ptszFileName, _TRUNCATE);
size_t filenameLen = mir_tstrlen(szFilename);
if (filenameLen > 4) {
diff --git a/src/modules/xml/xmlParser.cpp b/src/modules/xml/xmlParser.cpp
index 04c82c59d3..21cf0a0548 100644
--- a/src/modules/xml/xmlParser.cpp
+++ b/src/modules/xml/xmlParser.cpp
@@ -202,7 +202,7 @@ wchar_t *myMultiByteToWideChar(const char *s, XMLNode::XMLCharEncoding ce)
return d;
}
static inline FILE *xfopen(XMLCSTR filename, XMLCSTR mode) { return _wfopen(filename, mode); }
-static inline int xstrlen(XMLCSTR c) { return (int)wcslen(c); }
+static inline size_t xstrlen(XMLCSTR c) { return wcslen(c); }
static inline int xstrnicmp(XMLCSTR c1, XMLCSTR c2, int l) { return _wcsnicmp(c1, c2, l);}
static inline int xstrncmp(XMLCSTR c1, XMLCSTR c2, int l) { return wcsncmp(c1, c2, l);}
static inline int xstricmp(XMLCSTR c1, XMLCSTR c2) { return _wcsicmp(c1, c2); }
@@ -236,7 +236,7 @@ char *myWideCharToMultiByte(const wchar_t *s)
return d;
}
static inline FILE *xfopen(XMLCSTR filename, XMLCSTR mode) { return fopen(filename, mode); }
-static inline int xstrlen(XMLCSTR c) { return (int)strlen(c); }
+static inline size_t xstrlen(XMLCSTR c) { return strlen(c); }
#ifdef __BORLANDC__
static inline int xstrnicmp(XMLCSTR c1, XMLCSTR c2, int l) { return strnicmp(c1, c2, l);}
static inline int xstricmp(XMLCSTR c1, XMLCSTR c2) { return stricmp(c1, c2); }