summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRozhuk Ivan <rozhuk.im@gmail.com>2014-12-02 05:19:23 +0000
committerRozhuk Ivan <rozhuk.im@gmail.com>2014-12-02 05:19:23 +0000
commit114f83d5d8a73b3f1435e09b1d91aff843e4ce15 (patch)
tree0805188bf6bcf5749d1e76d5d1e73ccb6cf41cc4
parent6e2b6b31bae6d69bff5271451e73eb08637b8118 (diff)
mir_snprintf(..., "%s", ...) -> strncpy_s(...)
build fix to prevous commit git-svn-id: http://svn.miranda-ng.org/main/trunk@11212 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--plugins/Clist_nicer/src/clcutils.cpp1
-rw-r--r--plugins/Clist_nicer/src/extBackg.cpp14
-rw-r--r--plugins/CrashDumper/src/upload.cpp10
-rw-r--r--plugins/ExternalAPI/m_folders.h4
-rw-r--r--plugins/FileAsMessage/src/dialog.cpp2
-rw-r--r--plugins/IEView/src/HTMLBuilder.cpp4
-rw-r--r--plugins/RecentContacts/src/options.cpp2
-rw-r--r--plugins/Scriver/src/utils.cpp2
-rw-r--r--plugins/Spamotron/src/bayes.cpp2
-rw-r--r--plugins/TabSRMM/src/msglog.cpp2
-rw-r--r--plugins/UserInfoEx/src/ex_import/classExImContactBase.cpp2
-rw-r--r--plugins/YahooGroups/src/services.cpp7
-rw-r--r--protocols/Dummy/src/dummy_proto.cpp4
-rw-r--r--protocols/IRCG/src/commandmonitor.cpp4
-rw-r--r--protocols/IcqOscarJ/src/UI/userinfotab.cpp5
-rw-r--r--protocols/MSN/src/msn_misc.cpp2
-rw-r--r--protocols/MSN/src/msn_opts.cpp2
-rw-r--r--protocols/MSN/src/msn_p2p.cpp2
-rw-r--r--protocols/MSN/src/msn_soapab.cpp4
-rw-r--r--protocols/MSN/src/msn_soapstore.cpp8
-rw-r--r--protocols/Tlen/src/tlen.cpp6
-rw-r--r--protocols/Tlen/src/tlen_file.cpp4
-rw-r--r--protocols/Tlen/src/tlen_iqid.cpp6
-rw-r--r--protocols/Tlen/src/tlen_muc.cpp2
-rw-r--r--protocols/Tlen/src/tlen_thread.cpp2
-rw-r--r--protocols/Xfire/src/Xfire_base.cpp2
-rw-r--r--protocols/Yahoo/src/yahoo.cpp18
-rw-r--r--src/core/stdfile/filerecvdlg.cpp2
-rw-r--r--src/core/stdfile/filesenddlg.cpp2
-rw-r--r--src/core/stdurl/urldialogs.cpp2
-rw-r--r--src/mir_core/langpack.cpp4
-rw-r--r--src/mir_core/path.cpp2
32 files changed, 66 insertions, 69 deletions
diff --git a/plugins/Clist_nicer/src/clcutils.cpp b/plugins/Clist_nicer/src/clcutils.cpp
index c700c5607c..f8026b4d2e 100644
--- a/plugins/Clist_nicer/src/clcutils.cpp
+++ b/plugins/Clist_nicer/src/clcutils.cpp
@@ -90,6 +90,7 @@ size_t MY_pathToAbsolute(const TCHAR *pSrc, TCHAR *pOut)
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));
diff --git a/plugins/Clist_nicer/src/extBackg.cpp b/plugins/Clist_nicer/src/extBackg.cpp
index d124c0cedc..74e848468d 100644
--- a/plugins/Clist_nicer/src/extBackg.cpp
+++ b/plugins/Clist_nicer/src/extBackg.cpp
@@ -973,7 +973,7 @@ static void BTN_ReadItem(char *itemName, char *file)
ImageItem *imgItem = g_ImageItems;
memset(&tmpItem, 0, sizeof(tmpItem));
- mir_snprintf(tmpItem.szName, SIZEOF(tmpItem.szName), "%s", &itemName[1]);
+ strncpy_s(tmpItem.szName, &itemName[1], _TRUNCATE);
tmpItem.width = GetPrivateProfileIntA(itemName, "Width", 16, file);
tmpItem.height = GetPrivateProfileIntA(itemName, "Height", 16, file);
tmpItem.xOff = GetPrivateProfileIntA(itemName, "xoff", 0, file);
@@ -1048,7 +1048,7 @@ static void BTN_ReadItem(char *itemName, char *file)
tmpItem.szService[0] = 0;
GetPrivateProfileStringA(itemName, "Service", "None", szBuffer, 1000, file);
if (_stricmp(szBuffer, "None")) {
- mir_snprintf(tmpItem.szService, 256, "%s", szBuffer);
+ strncpy_s(tmpItem.szService, szBuffer, _TRUNCATE);
tmpItem.dwFlags |= BUTTON_ISSERVICE;
tmpItem.uId = nextButtonID++;
}
@@ -1057,7 +1057,7 @@ static void BTN_ReadItem(char *itemName, char *file)
tmpItem.szService[0] = 0;
GetPrivateProfileStringA(itemName, "Service", "None", szBuffer, 1000, file);
if (_stricmp(szBuffer, "None")) {
- mir_snprintf(tmpItem.szService, 256, "%s", szBuffer);
+ strncpy_s(tmpItem.szService, szBuffer, _TRUNCATE);
tmpItem.dwFlags |= BUTTON_ISPROTOSERVICE;
tmpItem.uId = nextButtonID++;
}
@@ -1067,10 +1067,10 @@ static void BTN_ReadItem(char *itemName, char *file)
GetPrivateProfileStringA(itemName, "Module", "None", szBuffer, 1000, file);
if (_stricmp(szBuffer, "None"))
- mir_snprintf(tmpItem.szModule, 256, "%s", szBuffer);
+ strncpy_s(tmpItem.szModule, szBuffer, _TRUNCATE);
GetPrivateProfileStringA(itemName, "Setting", "None", szBuffer, 1000, file);
if (_stricmp(szBuffer, "None"))
- mir_snprintf(tmpItem.szSetting, 256, "%s", szBuffer);
+ strncpy_s(tmpItem.szSetting, szBuffer, _TRUNCATE);
if (GetPrivateProfileIntA(itemName, "contact", 0, file) != 0)
tmpItem.dwFlags |= BUTTON_DBACTIONONCONTACT;
@@ -1286,10 +1286,10 @@ void LoadPerContactSkins(TCHAR *tszFileName)
char UIN[40];
switch (dbv.type) {
case DBVT_DWORD:
- mir_snprintf(UIN, 40, "%d", dbv.dVal);
+ mir_snprintf(UIN, SIZEOF(UIN), "%d", dbv.dVal);
break;
case DBVT_ASCIIZ:
- mir_snprintf(UIN, 40, "%s", dbv.pszVal);
+ strncpy_s(UIN, dbv.pszVal, _TRUNCATE);
db_free(&dbv);
break;
default:
diff --git a/plugins/CrashDumper/src/upload.cpp b/plugins/CrashDumper/src/upload.cpp
index 7b1d2350aa..fccdc858ce 100644
--- a/plugins/CrashDumper/src/upload.cpp
+++ b/plugins/CrashDumper/src/upload.cpp
@@ -40,10 +40,10 @@ void GetLoginStr(char* user, size_t szuser, char* pass)
DBVARIANT dbv;
if (db_get_s(NULL, PluginName, "Username", &dbv) == 0) {
- mir_snprintf(user, szuser, "%s", dbv.pszVal);
+ strncpy_s(user, szuser, dbv.pszVal, _TRUNCATE);
db_free(&dbv);
- }
- else user[0] = 0;
+ } else
+ user[0] = 0;
if (db_get_s(NULL, PluginName, "Password", &dbv) == 0) {
BYTE hash[16];
@@ -56,8 +56,8 @@ void GetLoginStr(char* user, size_t szuser, char* pass)
arrayToHex(hash, sizeof(hash), pass);
db_free(&dbv);
- }
- else pass[0] = 0;
+ } else
+ pass[0] = 0;
}
void OpenAuthUrl(const char* url)
diff --git a/plugins/ExternalAPI/m_folders.h b/plugins/ExternalAPI/m_folders.h
index c54f7c3d18..4256e02355 100644
--- a/plugins/ExternalAPI/m_folders.h
+++ b/plugins/ExternalAPI/m_folders.h
@@ -172,7 +172,7 @@ __inline static INT_PTR FoldersGetCustomPath(HANDLE hFolderEntry, char *path, co
if (res) {
char buffer[MAX_PATH];
PathToAbsolute(notFound, buffer);
- mir_snprintf(path, size, "%s", buffer);
+ strncpy_s(path, size, buffer, _TRUNCATE);
}
return res;
@@ -205,7 +205,7 @@ __inline static INT_PTR FoldersGetCustomPathEx(HANDLE hFolderEntry, char *path,
if (res) {
char buffer[MAX_PATH];
PathToAbsolute(notFound, buffer);
- mir_snprintf(path, size, "%s", buffer);
+ strncpy_s(path, size, buffer, _TRUNCATE);
}
if (path[0] != '\0')
diff --git a/plugins/FileAsMessage/src/dialog.cpp b/plugins/FileAsMessage/src/dialog.cpp
index 21aa2775ba..9cc63c3929 100644
--- a/plugins/FileAsMessage/src/dialog.cpp
+++ b/plugins/FileAsMessage/src/dialog.cpp
@@ -1191,7 +1191,7 @@ INT_PTR CALLBACK DialogProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam
if(size != -1)
mir_snprintf(str, SIZEOF(str), Translate("Size: %d bytes"), size);
else
- mir_snprintf(str, SIZEOF(str), "%s", Translate("Can't get a file size"));
+ strncpy_s(str, Translate("Can't get a file size"), _TRUNCATE);
SetDlgItemText(hDlg, IDC_FILESIZE, str);
break;
diff --git a/plugins/IEView/src/HTMLBuilder.cpp b/plugins/IEView/src/HTMLBuilder.cpp
index 3bc97efae4..08d7f0ac50 100644
--- a/plugins/IEView/src/HTMLBuilder.cpp
+++ b/plugins/IEView/src/HTMLBuilder.cpp
@@ -219,7 +219,7 @@ void HTMLBuilder::getUINs(MCONTACT hContact, char *&uinIn, char *&uinOut)
if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM) & ci)) {
switch (ci.type) {
case CNFT_ASCIIZ:
- mir_snprintf(buf, SIZEOF(buf), "%s", ci.pszVal);
+ strncpy_s(buf, (char*)ci.pszVal, _TRUNCATE);
mir_free(ci.pszVal);
break;
case CNFT_DWORD:
@@ -233,7 +233,7 @@ void HTMLBuilder::getUINs(MCONTACT hContact, char *&uinIn, char *&uinOut)
if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM) & ci)) {
switch (ci.type) {
case CNFT_ASCIIZ:
- mir_snprintf(buf, SIZEOF(buf), "%s", ci.pszVal);
+ strncpy_s(buf, (char*)ci.pszVal, _TRUNCATE);
mir_free(ci.pszVal);
break;
case CNFT_DWORD:
diff --git a/plugins/RecentContacts/src/options.cpp b/plugins/RecentContacts/src/options.cpp
index e5c587613d..31462b55db 100644
--- a/plugins/RecentContacts/src/options.cpp
+++ b/plugins/RecentContacts/src/options.cpp
@@ -17,7 +17,7 @@ INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
mir_snprintf(str, SIZEOF(str), "%d", LastUCOpt.MaxShownContacts);
SetDlgItemTextA(hwndDlg, IDC_SHOWNCONTACTS, str);
- mir_snprintf(str, SIZEOF(str), "%s", LastUCOpt.DateTimeFormat.c_str());
+ strncpy_s(str, LastUCOpt.DateTimeFormat.c_str(), _TRUNCATE);
SetDlgItemTextA(hwndDlg, IDC_DATETIME, str);
SetWindowLongPtr(hwndDlg,GWLP_USERDATA,lParam);
diff --git a/plugins/Scriver/src/utils.cpp b/plugins/Scriver/src/utils.cpp
index 96d8e1a2ad..c3b663bd3f 100644
--- a/plugins/Scriver/src/utils.cpp
+++ b/plugins/Scriver/src/utils.cpp
@@ -441,7 +441,7 @@ void GetContactUniqueId(SrmmWindowData *dat, char *buf, int maxlen)
if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci)) {
switch (ci.type) {
case CNFT_ASCIIZ:
- mir_snprintf(buf, maxlen, "%s", ci.pszVal);
+ strncpy_s(buf, maxlen, (char*)ci.pszVal, _TRUNCATE);
mir_free(ci.pszVal);
break;
case CNFT_DWORD:
diff --git a/plugins/Spamotron/src/bayes.cpp b/plugins/Spamotron/src/bayes.cpp
index d444e12411..d7b7518182 100644
--- a/plugins/Spamotron/src/bayes.cpp
+++ b/plugins/Spamotron/src/bayes.cpp
@@ -28,7 +28,7 @@ int CheckBayes()
if (hBayesFolder)
FoldersGetCustomPath(hBayesFolder, bayesdb_fullpath, MAX_PATH, bayesdb_tmp);
else
- mir_snprintf(bayesdb_fullpath, SIZEOF(bayesdb_fullpath), "%s", bayesdb_tmp);
+ strncpy_s(bayesdb_fullpath, bayesdb_tmp, _TRUNCATE);
strcat(bayesdb_fullpath, "\\"BAYESDB_FILENAME);
if (_access(bayesdb_fullpath,0) == 0)
diff --git a/plugins/TabSRMM/src/msglog.cpp b/plugins/TabSRMM/src/msglog.cpp
index e0b8ef4229..e0aa1f7e61 100644
--- a/plugins/TabSRMM/src/msglog.cpp
+++ b/plugins/TabSRMM/src/msglog.cpp
@@ -1197,7 +1197,7 @@ static DWORD CALLBACK LogStreamInEvents(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG
static void SetupLogFormatting(TWindowData *dat)
{
if (dat->hHistoryEvents)
- mir_snprintf(dat->szMicroLf, SIZEOF(dat->szMicroLf), "%s", "\\v\\cf%d \\ ~-+%d+-~\\v0 ");
+ strncpy_s(dat->szMicroLf, "\\v\\cf%d \\ ~-+%d+-~\\v0 ", _TRUNCATE);
else
mir_snprintf(dat->szMicroLf, SIZEOF(dat->szMicroLf), "%s\\par\\ltrpar\\sl-1%s ", GetRTFFont(MSGDLGFONTCOUNT), GetRTFFont(MSGDLGFONTCOUNT));
}
diff --git a/plugins/UserInfoEx/src/ex_import/classExImContactBase.cpp b/plugins/UserInfoEx/src/ex_import/classExImContactBase.cpp
index 12201aea07..d0f2a7e6f7 100644
--- a/plugins/UserInfoEx/src/ex_import/classExImContactBase.cpp
+++ b/plugins/UserInfoEx/src/ex_import/classExImContactBase.cpp
@@ -297,7 +297,7 @@ void CExImContactBase::toIni(FILE* file, int modCount)
mir_snprintf(name, SIZEOF(name),"(UNKNOWN) (%s)", _pszProto);
}
else
- mir_snprintf(name, SIZEOF(name),"%s", "(UNKNOWN)");
+ strncpy_s(name, "(UNKNOWN)", _TRUNCATE);
}
else {
// Proto loadet - GetContactName(hContact,pszProto,0)
diff --git a/plugins/YahooGroups/src/services.cpp b/plugins/YahooGroups/src/services.cpp
index d0de915c21..645bae1282 100644
--- a/plugins/YahooGroups/src/services.cpp
+++ b/plugins/YahooGroups/src/services.cpp
@@ -93,8 +93,9 @@ void AddNewGroup(char *newGroup)
char tmp[128];
char group[1024];
+
*group = 1;
- mir_snprintf((group + 1), (SIZEOF(group) - 1), "%s", newGroup);
+ strncpy_s((group + 1), (SIZEOF(group) - 1), newGroup, _TRUNCATE);
mir_snprintf(tmp, SIZEOF(tmp), "%d", index);
const int MAX_SIZE = 1024;
@@ -129,7 +130,7 @@ void CreateGroup(char *group)
strncat(buffer, sub, sizeof(buffer));
}
else{
- mir_snprintf(buffer, SIZEOF(buffer), "%s", sub);
+ strncpy_s(buffer, sub, _TRUNCATE);
}
if (!availableGroups.Contains(buffer))
@@ -149,7 +150,7 @@ void CreateGroup(char *group)
strncat(buffer, sub, sizeof(buffer));
}
else{
- mir_snprintf(buffer, SIZEOF(buffer), "%s", sub);
+ strncpy_s(buffer, sub, _TRUNCATE);
}
if (!availableGroups.Contains(buffer))
diff --git a/protocols/Dummy/src/dummy_proto.cpp b/protocols/Dummy/src/dummy_proto.cpp
index 4343018c35..72819d962b 100644
--- a/protocols/Dummy/src/dummy_proto.cpp
+++ b/protocols/Dummy/src/dummy_proto.cpp
@@ -75,7 +75,7 @@ DWORD_PTR CDummyProto::GetCaps(int type, MCONTACT hContact)
if (uniqueIdSetting[0] == '\0') {
ptrA setting(getStringA(DUMMY_ID_TEXT));
if (setting != NULL)
- mir_snprintf(uniqueIdSetting, SIZEOF(uniqueIdSetting), "%s", setting);
+ strncpy_s(uniqueIdSetting, setting, _TRUNCATE);
}
return (DWORD_PTR)uniqueIdSetting;
@@ -83,7 +83,7 @@ DWORD_PTR CDummyProto::GetCaps(int type, MCONTACT hContact)
if (uniqueIdText[0] == '\0') {
ptrA setting(getStringA(DUMMY_ID_SETTING));
if (setting != NULL)
- mir_snprintf(uniqueIdText, SIZEOF(uniqueIdText), "%s", setting);
+ strncpy_s(uniqueIdText, setting, _TRUNCATE);
}
return (DWORD_PTR)uniqueIdText;
}
diff --git a/protocols/IRCG/src/commandmonitor.cpp b/protocols/IRCG/src/commandmonitor.cpp
index d70529a159..a96cd06395 100644
--- a/protocols/IRCG/src/commandmonitor.cpp
+++ b/protocols/IRCG/src/commandmonitor.cpp
@@ -246,9 +246,9 @@ void __cdecl CIrcProto::ResolveIPThread(LPVOID di)
IN_ADDR in;
memcpy(&in, myhost->h_addr, 4);
if (ipr->iType == IP_AUTO)
- mir_snprintf(m_myHost, SIZEOF(m_myHost), "%s", inet_ntoa(in));
+ strncpy_s(m_myHost, inet_ntoa(in), _TRUNCATE);
else
- mir_snprintf(m_mySpecifiedHostIP, SIZEOF(m_mySpecifiedHostIP), "%s", inet_ntoa(in));
+ strncpy_s(m_mySpecifiedHostIP, inet_ntoa(in), _TRUNCATE);
}
}
}
diff --git a/protocols/IcqOscarJ/src/UI/userinfotab.cpp b/protocols/IcqOscarJ/src/UI/userinfotab.cpp
index 3dbdbdbd2f..4808b0ef7e 100644
--- a/protocols/IcqOscarJ/src/UI/userinfotab.cpp
+++ b/protocols/IcqOscarJ/src/UI/userinfotab.cpp
@@ -117,9 +117,8 @@ static void SetValue(CIcqProto* ppro, HWND hwndDlg, int idCtrl, MCONTACT hContac
}
mir_snprintf(str, SIZEOF(str), "%s (%s)", pszStatus, pXName);
SAFE_FREE((void**)&pXName);
- }
- else
- mir_snprintf(str, SIZEOF(str), "%s", pszStatus);
+ } else
+ strncpy_s(str, pszStatus, _TRUNCATE);
bUtf = 1;
SAFE_FREE(&pszStatus);
diff --git a/protocols/MSN/src/msn_misc.cpp b/protocols/MSN/src/msn_misc.cpp
index 74458df7bd..b04aad206f 100644
--- a/protocols/MSN/src/msn_misc.cpp
+++ b/protocols/MSN/src/msn_misc.cpp
@@ -663,7 +663,7 @@ int ThreadData::sendPacket(const char* cmd, const char* fmt, ...)
int thisTrid = 0;
if (fmt == NULL)
- mir_snprintf(str, strsize, "%s", cmd);
+ strncpy_s(str, strsize, cmd, _TRUNCATE);
else {
thisTrid = InterlockedIncrement(&mTrid);
if (fmt[0] == '\0')
diff --git a/protocols/MSN/src/msn_opts.cpp b/protocols/MSN/src/msn_opts.cpp
index f0653b83b0..9026ff912e 100644
--- a/protocols/MSN/src/msn_opts.cpp
+++ b/protocols/MSN/src/msn_opts.cpp
@@ -329,7 +329,7 @@ static INT_PTR CALLBACK DlgProcMsnConnOpts(HWND hwndDlg, UINT msg, WPARAM wParam
gethst = 0;
if (gethst == 0)
- mir_snprintf(ipaddr, SIZEOF(ipaddr), "%s", proto->msnLoggedIn ? proto->MyConnection.GetMyExtIPStr() : "");
+ strncpy_s(ipaddr, (proto->msnLoggedIn ? proto->MyConnection.GetMyExtIPStr() : ""), _TRUNCATE);
SendDlgItemMessage(hwndDlg, IDC_HOSTOPT, CB_SETCURSEL, gethst, 0);
if (ipaddr[0])
diff --git a/protocols/MSN/src/msn_p2p.cpp b/protocols/MSN/src/msn_p2p.cpp
index a6cb19e8e0..345a081f35 100644
--- a/protocols/MSN/src/msn_p2p.cpp
+++ b/protocols/MSN/src/msn_p2p.cpp
@@ -1398,7 +1398,7 @@ void CMsnProto::p2p_startConnect(const char* wlid, const char* szCallID, const c
newThread->mType = SERVER_P2P_DIRECT;
newThread->mInitialContactWLID = mir_strdup(wlid);
- mir_snprintf(newThread->mCookie, SIZEOF(newThread->mCookie), "%s", szCallID);
+ strncpy_s(newThread->mCookie, szCallID, _TRUNCATE);
mir_snprintf(newThread->mServer, SIZEOF(newThread->mServer),
ipv6 ? "[%s]:%s" : "%s:%s", pAddrTokBeg, pPortTokBeg);
diff --git a/protocols/MSN/src/msn_soapab.cpp b/protocols/MSN/src/msn_soapab.cpp
index 22b92fe25b..88acf26373 100644
--- a/protocols/MSN/src/msn_soapab.cpp
+++ b/protocols/MSN/src/msn_soapab.cpp
@@ -637,8 +637,8 @@ bool CMsnProto::MSN_ABFind(const char* szMethod, const char* szGuid, bool deltas
}
ezxml_t abinf = ezxml_child(ab, "abInfo");
- mir_snprintf(mycid, SIZEOF(mycid), "%s", ezxml_txt(ezxml_child(abinf, "OwnerCID")));
- mir_snprintf(mypuid, SIZEOF(mypuid), "%s", ezxml_txt(ezxml_child(abinf, "ownerPuid")));
+ strncpy_s(mycid, ezxml_txt(ezxml_child(abinf, "OwnerCID")), _TRUNCATE);
+ strncpy_s(mypuid, ezxml_txt(ezxml_child(abinf, "ownerPuid")), _TRUNCATE);
if (MyOptions.ManageServer) {
ezxml_t grp = ezxml_get(body, szGroups, 0, "Group", -1);
diff --git a/protocols/MSN/src/msn_soapstore.cpp b/protocols/MSN/src/msn_soapstore.cpp
index 1028e403cc..ccec429d07 100644
--- a/protocols/MSN/src/msn_soapstore.cpp
+++ b/protocols/MSN/src/msn_soapstore.cpp
@@ -257,7 +257,7 @@ bool CMsnProto::MSN_StoreGetProfile(bool allowRecurse)
UpdateStoreHost("GetProfile", body ? storeUrl : NULL);
- mir_snprintf(proresid, SIZEOF(proresid), "%s", ezxml_txt(ezxml_child(body, "ResourceID")));
+ strncpy_s(proresid, ezxml_txt(ezxml_child(body, "ResourceID")), _TRUNCATE);
ezxml_t expr = ezxml_child(body, "ExpressionProfile");
if (expr == NULL) {
@@ -272,10 +272,10 @@ bool CMsnProto::MSN_StoreGetProfile(bool allowRecurse)
const char* szStatus = ezxml_txt(ezxml_child(expr, "PersonalStatus"));
replaceStr(msnLastStatusMsg, szStatus);
- mir_snprintf(expresid, SIZEOF(expresid), "%s", ezxml_txt(ezxml_child(expr, "ResourceID")));
+ strncpy_s(expresid, ezxml_txt(ezxml_child(expr, "ResourceID")), _TRUNCATE);
ezxml_t photo = ezxml_child(expr, "Photo");
- mir_snprintf(photoid, SIZEOF(photoid), "%s", ezxml_txt(ezxml_child(photo, "ResourceID")));
+ strncpy_s(photoid, ezxml_txt(ezxml_child(photo, "ResourceID")), _TRUNCATE);
ezxml_t docstr = ezxml_get(photo, "DocumentStreams", 0, "DocumentStream", -1);
while (docstr) {
@@ -565,7 +565,7 @@ bool CMsnProto::MSN_StoreCreateDocument(const TCHAR *sztName, const char *szMime
if (status == 200) {
ezxml_t xmlm = ezxml_parse_str(tResult, strlen(tResult));
ezxml_t bdy = getSoapResponse(xmlm, "CreateDocument");
- mir_snprintf(photoid, SIZEOF(photoid), "%s", ezxml_txt(bdy));
+ strncpy_s(photoid, ezxml_txt(bdy), _TRUNCATE);
ezxml_free(xmlm);
}
else if (status == 500) {
diff --git a/protocols/Tlen/src/tlen.cpp b/protocols/Tlen/src/tlen.cpp
index 38249081ca..81ef9b9d2e 100644
--- a/protocols/Tlen/src/tlen.cpp
+++ b/protocols/Tlen/src/tlen.cpp
@@ -239,11 +239,11 @@ int TlenProtocol::OnModulesLoaded(WPARAM wParam, LPARAM lParam)
if (db_get_w(hContact, m_szModuleName, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE)
db_set_w(hContact, m_szModuleName, "Status", ID_STATUS_OFFLINE);
- mir_snprintf(str, SIZEOF(str), "%s", LPGEN("Incoming mail"));
+ strncpy_s(str, LPGEN("Incoming mail"), _TRUNCATE);
SkinAddNewSoundEx("TlenMailNotify", m_szModuleName, str);
- mir_snprintf(str, SIZEOF(str), "%s", LPGEN("Alert"));
+ strncpy_s(str, LPGEN("Alert"), _TRUNCATE);
SkinAddNewSoundEx("TlenAlertNotify", m_szModuleName, str);
- mir_snprintf(str, SIZEOF(str), "%s", LPGEN("Voice chat"));
+ strncpy_s(str, LPGEN("Voice chat"), _TRUNCATE);
SkinAddNewSoundEx("TlenVoiceNotify", m_szModuleName, str);
HookProtoEvent(ME_USERINFO_INITIALISE, &TlenProtocol::UserInfoInit);
diff --git a/protocols/Tlen/src/tlen_file.cpp b/protocols/Tlen/src/tlen_file.cpp
index b0460c24a6..ef073b9ec2 100644
--- a/protocols/Tlen/src/tlen_file.cpp
+++ b/protocols/Tlen/src/tlen_file.cpp
@@ -276,7 +276,7 @@ static void TlenFileSendParse(TLEN_FILE_TRANSFER *ft)
t++;
else
t = ft->files[i];
- mir_snprintf(filename, (SIZEOF(filename) - 1), "%s", t);
+ strncpy_s(filename, t, _TRUNCATE);
TlenP2PPacketPackBuffer(packet, filename, sizeof(filename));
}
TlenP2PPacketSend(ft->s, packet);
@@ -572,7 +572,7 @@ void TlenProcessF(XmlNode *node, ThreadData *info)
if (strchr(from, '@') == NULL) {
mir_snprintf(jid, SIZEOF(jid), "%s@%s", from, info->server);
} else {
- mir_snprintf(jid, SIZEOF(jid), "%s", from);
+ strncpy_s(jid, from, _TRUNCATE);
}
if ((e=TlenXmlGetAttrValue(node, "e")) != NULL) {
diff --git a/protocols/Tlen/src/tlen_iqid.cpp b/protocols/Tlen/src/tlen_iqid.cpp
index f041d712ca..a03d1a7614 100644
--- a/protocols/Tlen/src/tlen_iqid.cpp
+++ b/protocols/Tlen/src/tlen_iqid.cpp
@@ -257,7 +257,7 @@ void TlenIqResultVcard(TlenProtocol *proto, XmlNode *iqNode)
if ((jid=TlenXmlGetAttrValue(itemNode, "jid")) != NULL) {
if (db_get(NULL, proto->m_szModuleName, "LoginServer", &dbv)) return;
if (strchr(jid, '@') != NULL) {
- mir_snprintf(text, SIZEOF(text), "%s", jid);
+ strncpy_s(text, jid, _TRUNCATE);
} else {
mir_snprintf(text, SIZEOF(text), "%s@%s", jid, dbv.pszVal); // Add @tlen.pl
}
@@ -419,7 +419,7 @@ void TlenIqResultSearch(TlenProtocol *proto, XmlNode *iqNode)
if (!strcmp(itemNode->name, "item")) {
if ((jid=TlenXmlGetAttrValue(itemNode, "jid")) != NULL) {
if (strchr(jid, '@') != NULL) {
- mir_snprintf(jsr.jid, SIZEOF(jsr.jid), "%s", jid);
+ strncpy_s(jsr.jid, jid, _TRUNCATE);
} else {
mir_snprintf(jsr.jid, SIZEOF(jsr.jid), "%s@%s", jid, dbv.pszVal);
}
@@ -467,7 +467,7 @@ void TlenIqResultSearch(TlenProtocol *proto, XmlNode *iqNode)
if (proto->searchJID != NULL) {
if (!found) {
if (strchr(proto->searchJID, '@') != NULL) {
- mir_snprintf(jsr.jid, SIZEOF(jsr.jid), "%s", proto->searchJID);
+ strncpy_s(jsr.jid, proto->searchJID, _TRUNCATE);
} else {
mir_snprintf(jsr.jid, SIZEOF(jsr.jid), "%s@%s", proto->searchJID, dbv.pszVal);
}
diff --git a/protocols/Tlen/src/tlen_muc.cpp b/protocols/Tlen/src/tlen_muc.cpp
index 0f406d9c77..9712af7339 100644
--- a/protocols/Tlen/src/tlen_muc.cpp
+++ b/protocols/Tlen/src/tlen_muc.cpp
@@ -154,7 +154,7 @@ static int TlenMUCSendPresence(TlenProtocol *proto, const char *roomID, const ch
if (nick != NULL) {
mir_snprintf(str, SIZEOF(str), "%s/%s", roomID, nick);
} else {
- mir_snprintf(str, SIZEOF(str), "%s", roomID);
+ strncpy_s(str, roomID, _TRUNCATE);
}
if ((jid = TlenTextEncode(str)) != NULL) {
switch (desiredStatus) {
diff --git a/protocols/Tlen/src/tlen_thread.cpp b/protocols/Tlen/src/tlen_thread.cpp
index c243fa11ec..9f714bbdb6 100644
--- a/protocols/Tlen/src/tlen_thread.cpp
+++ b/protocols/Tlen/src/tlen_thread.cpp
@@ -1190,7 +1190,7 @@ static void TlenProcessV(XmlNode *node, ThreadData *info)
if (strchr(from, '@') == NULL) {
mir_snprintf(jid, SIZEOF(jid), "%s@%s", from, info->server);
} else {
- mir_snprintf(jid, SIZEOF(jid), "%s", from);
+ strncpy_s(jid, from, _TRUNCATE);
}
if ((e=TlenXmlGetAttrValue(node, "e")) != NULL) {
if (!strcmp(e, "1")) {
diff --git a/protocols/Xfire/src/Xfire_base.cpp b/protocols/Xfire/src/Xfire_base.cpp
index 6363c0e0dd..602a198997 100644
--- a/protocols/Xfire/src/Xfire_base.cpp
+++ b/protocols/Xfire/src/Xfire_base.cpp
@@ -524,7 +524,7 @@ BOOL Xfire_base::getGamename(unsigned int gameid, char* out, int outsize){
char dbstr[80] = "";
mir_snprintf(dbstr, XFIRE_MAXSIZEOFGAMENAME, "customgamename_%d", gameid);
if (!db_get(NULL, protocolname, dbstr, &dbv)) {
- mir_snprintf(out, outsize, "%s", dbv.pszVal);
+ strncpy_s(out, outsize, dbv.pszVal, _TRUNCATE);
db_free(&dbv);
return TRUE;
}
diff --git a/protocols/Yahoo/src/yahoo.cpp b/protocols/Yahoo/src/yahoo.cpp
index 44e313320e..eb920fe9ba 100644
--- a/protocols/Yahoo/src/yahoo.cpp
+++ b/protocols/Yahoo/src/yahoo.cpp
@@ -794,12 +794,12 @@ void CYahooProto::ext_contact_added(const char *myid, const char *who, const cha
if (lname && fname)
mir_snprintf(nick, SIZEOF(nick), "%s %s", fname, lname);
else if (lname)
- mir_snprintf(nick, SIZEOF(nick), "%s", lname);
+ strncpy_s(nick, lname, _TRUNCATE);
else if (fname)
- mir_snprintf(nick, SIZEOF(nick), "%s", fname);
+ strncpy_s(nick, fname, _TRUNCATE);
- if (nick[0] == '\0')
- mir_snprintf(nick, SIZEOF(nick), "%s", who);
+ if (nick[0] == '\0')
+ strncpy_s(nick, who, _TRUNCATE);
if (fname) SetStringUtf(hContact, "FirstName", fname);
if (lname) SetStringUtf(hContact, "LastName", lname);
@@ -1546,14 +1546,10 @@ void CYahooProto::ext_login(enum yahoo_status login_mode)
if (host[0] == '\0') {
if (!getString(YAHOO_LOGINSERVER, &dbv)) {
- mir_snprintf(host, SIZEOF(host), "%s", dbv.pszVal);
+ strncpy_s(host, dbv.pszVal, _TRUNCATE);
db_free(&dbv);
- }
- else {
- mir_snprintf(host, SIZEOF(host), "%s",
- getByte("YahooJapan",0) != 0 ? YAHOO_DEFAULT_JAPAN_LOGIN_SERVER :
- YAHOO_DEFAULT_LOGIN_SERVER
- );
+ } else {
+ strncpy_s(host, (getByte("YahooJapan",0) ? YAHOO_DEFAULT_JAPAN_LOGIN_SERVER : YAHOO_DEFAULT_LOGIN_SERVER), _TRUNCATE);
}
}
diff --git a/src/core/stdfile/filerecvdlg.cpp b/src/core/stdfile/filerecvdlg.cpp
index 9509e14dda..8a1ff1b5b7 100644
--- a/src/core/stdfile/filerecvdlg.cpp
+++ b/src/core/stdfile/filerecvdlg.cpp
@@ -272,7 +272,7 @@ INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
switch (ci.type) {
case CNFT_ASCIIZ:
hasName = 1;
- mir_snprintf(buf, SIZEOF(buf), "%s", ci.pszVal);
+ strncpy_s(buf, (char*)ci.pszVal, _TRUNCATE);
mir_free(ci.pszVal);
break;
case CNFT_DWORD:
diff --git a/src/core/stdfile/filesenddlg.cpp b/src/core/stdfile/filesenddlg.cpp
index f9be264353..9c98a4f108 100644
--- a/src/core/stdfile/filesenddlg.cpp
+++ b/src/core/stdfile/filesenddlg.cpp
@@ -251,7 +251,7 @@ INT_PTR CALLBACK DlgProcSendFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
switch (ci.type) {
case CNFT_ASCIIZ:
hasName = 1;
- mir_snprintf(buf, SIZEOF(buf), "%s", ci.pszVal);
+ strncpy_s(buf, (char*)ci.pszVal, _TRUNCATE);
mir_free(ci.pszVal);
break;
case CNFT_DWORD:
diff --git a/src/core/stdurl/urldialogs.cpp b/src/core/stdurl/urldialogs.cpp
index 9911a05f83..0bd93f1190 100644
--- a/src/core/stdurl/urldialogs.cpp
+++ b/src/core/stdurl/urldialogs.cpp
@@ -50,7 +50,7 @@ static void sttUpdateTitle(HWND hwndDlg, MCONTACT hContact)
switch(ci.type) {
case CNFT_ASCIIZ:
hasName = 1;
- mir_snprintf(buf, SIZEOF(buf), "%s", ci.pszVal);
+ strncpy_s(buf, (char*)ci.pszVal, _TRUNCATE);
mir_free(ci.pszVal);
break;
case CNFT_DWORD:
diff --git a/src/mir_core/langpack.cpp b/src/mir_core/langpack.cpp
index 2e0b692cc4..362e1230ba 100644
--- a/src/mir_core/langpack.cpp
+++ b/src/mir_core/langpack.cpp
@@ -329,8 +329,8 @@ static int LoadLangDescr(LANGPACK_INFO &lpinfo, FILE *fp, char *line, int &start
return 3;
*pszColon++ = 0;
- if (!mir_strcmp(line, "Language")) {
- mir_snprintf(szLanguage, SIZEOF(szLanguage), "%s", pszColon);
+ if (!mir_strcmp(line, "Language")) {
+ strncpy_s(szLanguage, pszColon, _TRUNCATE);
lrtrim(szLanguage);
}
else if (!mir_strcmp(line, "Last-Modified-Using")) {
diff --git a/src/mir_core/path.cpp b/src/mir_core/path.cpp
index fbc3cff04b..d4148f457d 100644
--- a/src/mir_core/path.cpp
+++ b/src/mir_core/path.cpp
@@ -67,7 +67,7 @@ MIR_CORE_DLL(int) PathToAbsolute(const char *pSrc, char *pOut, const char *base)
char buf[MAX_PATH];
if (pSrc[0] < ' ')
- return mir_snprintf(pOut, MAX_PATH, "%s", pSrc);
+ strncpy_s(pOut, MAX_PATH, pSrc, _TRUNCATE);
if (PathIsAbsolute(pSrc))
return GetFullPathNameA(pSrc, MAX_PATH, pOut, NULL);