summaryrefslogtreecommitdiff
path: root/plugins/TabSRMM
diff options
context:
space:
mode:
authorRozhuk Ivan <rozhuk.im@gmail.com>2014-12-02 03:47:27 +0000
committerRozhuk Ivan <rozhuk.im@gmail.com>2014-12-02 03:47:27 +0000
commit6e2b6b31bae6d69bff5271451e73eb08637b8118 (patch)
treeca636f1497e4cc6980736d56a7ff61e3a6f88079 /plugins/TabSRMM
parentd83beb598f0944dcb944524b1d27525dc320cf18 (diff)
mir_sntprintf(..., _T("%s"), ...) -> _tcsncpy_s(..., ..., _TRUNCATE)
fix some x64 ptr truncations git-svn-id: http://svn.miranda-ng.org/main/trunk@11211 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/TabSRMM')
-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
21 files changed, 66 insertions, 70 deletions
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;