diff options
author | Rozhuk Ivan <rozhuk.im@gmail.com> | 2014-12-02 03:47:27 +0000 |
---|---|---|
committer | Rozhuk Ivan <rozhuk.im@gmail.com> | 2014-12-02 03:47:27 +0000 |
commit | 6e2b6b31bae6d69bff5271451e73eb08637b8118 (patch) | |
tree | ca636f1497e4cc6980736d56a7ff61e3a6f88079 /src | |
parent | d83beb598f0944dcb944524b1d27525dc320cf18 (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 'src')
-rw-r--r-- | src/core/stdauth/auth.cpp | 2 | ||||
-rw-r--r-- | src/core/stdauth/authdialogs.cpp | 8 | ||||
-rw-r--r-- | src/core/stdchat/src/window.cpp | 2 | ||||
-rw-r--r-- | src/core/stdfile/filexferdlg.cpp | 4 | ||||
-rw-r--r-- | src/core/stdmsg/src/msgdialog.cpp | 4 | ||||
-rw-r--r-- | src/modules/chat/log.cpp | 2 | ||||
-rw-r--r-- | src/modules/chat/tools.cpp | 4 | ||||
-rw-r--r-- | src/modules/clist/clistmod.cpp | 2 | ||||
-rw-r--r-- | src/modules/fonts/FontOptions.cpp | 4 | ||||
-rw-r--r-- | src/modules/fonts/services.cpp | 6 | ||||
-rw-r--r-- | src/modules/netlib/netlibautoproxy.cpp | 2 | ||||
-rw-r--r-- | src/modules/skin/sounds.cpp | 2 | ||||
-rw-r--r-- | src/modules/utils/bmpfilter.cpp | 2 | ||||
-rw-r--r-- | src/modules/xml/xmlParser.cpp | 4 |
14 files changed, 25 insertions, 23 deletions
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); } |