summaryrefslogtreecommitdiff
path: root/plugins/TabSRMM/src/msgdlgutils.cpp
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/src/msgdlgutils.cpp
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/src/msgdlgutils.cpp')
-rw-r--r--plugins/TabSRMM/src/msgdlgutils.cpp43
1 files changed, 18 insertions, 25 deletions
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)