From 44ac196462f6149c0d8355dfecebcef50a6ba2d8 Mon Sep 17 00:00:00 2001 From: Mataes Date: Sat, 31 Mar 2018 12:43:21 +0300 Subject: IEView: mir_strcpy and mir_wstrcpy replaced to strncpy_s and wcsncpy_s --- plugins/IEView/src/ChatHTMLBuilder.cpp | 4 ++-- plugins/IEView/src/HistoryHTMLBuilder.cpp | 4 ++-- plugins/IEView/src/MUCCHTMLBuilder.cpp | 4 ++-- plugins/IEView/src/Options.cpp | 38 +++++++++++++++--------------- plugins/IEView/src/ScriverHTMLBuilder.cpp | 8 +++---- plugins/IEView/src/TabSRMMHTMLBuilder.cpp | 8 +++---- plugins/IEView/src/TemplateHTMLBuilder.cpp | 6 ++--- 7 files changed, 36 insertions(+), 36 deletions(-) (limited to 'plugins') diff --git a/plugins/IEView/src/ChatHTMLBuilder.cpp b/plugins/IEView/src/ChatHTMLBuilder.cpp index d3f5cf2847..22e77eef4e 100644 --- a/plugins/IEView/src/ChatHTMLBuilder.cpp +++ b/plugins/IEView/src/ChatHTMLBuilder.cpp @@ -74,9 +74,9 @@ void ChatHTMLBuilder::loadMsgDlgFont(int i, LOGFONTA * lf, COLORREF * colour) lf->lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; mir_snprintf(str, "Font%d", i); if (db_get(NULL, CHATFONTMOD, str, &dbv)) - mir_strcpy(lf->lfFaceName, "Verdana"); + strncpy_s(lf->lfFaceName, "Verdana", _TRUNCATE); else { - mir_strncpy(lf->lfFaceName, dbv.pszVal, sizeof(lf->lfFaceName)); + strncpy_s(lf->lfFaceName, dbv.pszVal, _TRUNCATE); db_free(&dbv); } } diff --git a/plugins/IEView/src/HistoryHTMLBuilder.cpp b/plugins/IEView/src/HistoryHTMLBuilder.cpp index abbc3f3065..ce1c3c65ef 100644 --- a/plugins/IEView/src/HistoryHTMLBuilder.cpp +++ b/plugins/IEView/src/HistoryHTMLBuilder.cpp @@ -124,9 +124,9 @@ void HistoryHTMLBuilder::loadMsgDlgFont(const char *dbSetting, LOGFONTA * lf, CO lf->lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; mir_snprintf(str, "Font.%s.Name", dbSetting); if (db_get(NULL, HPPMOD, str, &dbv)) - mir_strcpy(lf->lfFaceName, "Verdana"); + strncpy_s(lf->lfFaceName, "Verdana", _TRUNCATE); else { - mir_strncpy(lf->lfFaceName, dbv.pszVal, sizeof(lf->lfFaceName)); + strncpy_s(lf->lfFaceName, dbv.pszVal, _TRUNCATE); db_free(&dbv); } } diff --git a/plugins/IEView/src/MUCCHTMLBuilder.cpp b/plugins/IEView/src/MUCCHTMLBuilder.cpp index 38a3d64089..d42635dc8f 100644 --- a/plugins/IEView/src/MUCCHTMLBuilder.cpp +++ b/plugins/IEView/src/MUCCHTMLBuilder.cpp @@ -70,9 +70,9 @@ void MUCCHTMLBuilder::loadMsgDlgFont(int i, LOGFONTA * lf, COLORREF * colour) lf->lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; mir_snprintf(str, "Font%dFace", i); if (db_get(NULL, MUCCMOD, str, &dbv)) - mir_strcpy(lf->lfFaceName, "Verdana"); + strncpy_s(lf->lfFaceName, "Verdana", _TRUNCATE); else { - mir_strncpy(lf->lfFaceName, dbv.pszVal, sizeof(lf->lfFaceName)); + strncpy_s(lf->lfFaceName, dbv.pszVal, _TRUNCATE); db_free(&dbv); } } diff --git a/plugins/IEView/src/Options.cpp b/plugins/IEView/src/Options.cpp index 5ca9fa0496..67584dad16 100644 --- a/plugins/IEView/src/Options.cpp +++ b/plugins/IEView/src/Options.cpp @@ -382,7 +382,7 @@ static void RefreshProtoList(HWND hwndDlg, int mode, bool protoTemplates) tvi.item.mask = TVIF_TEXT | TVIF_PARAM | TVIF_IMAGE | TVIF_STATE | TVIF_SELECTEDIMAGE; tvi.item.stateMask = TVIS_SELECTED | TVIS_STATEIMAGEMASK; if (i == 0) - mir_strcpy(protoName, Translate("Default")); + strncpy_s(protoName, Translate("Default"), _TRUNCATE); else CallProtoService(proto->getProtocolName(), PS_GETNAME, sizeof(protoName), (LPARAM)protoName); @@ -1506,7 +1506,7 @@ void Options::init() proto->setSRMMFlags(db_get_dw(NULL, ieviewModuleName, dbsName, 16128)); mir_snprintf(dbsName, "%s.%s", proto->getProtocolName(), DBS_SRMM_BACKGROUND); if (!db_get(NULL, ieviewModuleName, dbsName, &dbv)) { - mir_strcpy(tmpPath, dbv.pszVal); + strncpy_s(tmpPath, dbv.pszVal, _TRUNCATE); if (strncmp(tmpPath, "http://", 7)) PathToAbsolute(dbv.pszVal, tmpPath); @@ -1515,7 +1515,7 @@ void Options::init() } mir_snprintf(dbsName, "%s.%s", proto->getProtocolName(), DBS_SRMM_CSS); if (!db_get(NULL, ieviewModuleName, dbsName, &dbv)) { - mir_strcpy(tmpPath, dbv.pszVal); + strncpy_s(tmpPath, dbv.pszVal, _TRUNCATE); if (strncmp(tmpPath, "http://", 7)) PathToAbsolute(dbv.pszVal, tmpPath); @@ -1524,7 +1524,7 @@ void Options::init() } mir_snprintf(dbsName, "%s.%s", proto->getProtocolName(), DBS_SRMM_TEMPLATE); if (!db_get(NULL, ieviewModuleName, dbsName, &dbv)) { - mir_strcpy(tmpPath, dbv.pszVal); + strncpy_s(tmpPath, dbv.pszVal, _TRUNCATE); PathToAbsolute(dbv.pszVal, tmpPath); proto->setSRMMTemplateFilename(tmpPath); db_free(&dbv); @@ -1539,7 +1539,7 @@ void Options::init() proto->setChatFlags(db_get_dw(NULL, ieviewModuleName, dbsName, 16128)); mir_snprintf(dbsName, "%s.%s", proto->getProtocolName(), DBS_CHAT_BACKGROUND); if (!db_get(NULL, ieviewModuleName, dbsName, &dbv)) { - mir_strcpy(tmpPath, dbv.pszVal); + strncpy_s(tmpPath, dbv.pszVal, _TRUNCATE); if (strncmp(tmpPath, "http://", 7)) PathToAbsolute(dbv.pszVal, tmpPath); @@ -1548,7 +1548,7 @@ void Options::init() } mir_snprintf(dbsName, "%s.%s", proto->getProtocolName(), DBS_CHAT_CSS); if (!db_get(NULL, ieviewModuleName, dbsName, &dbv)) { - mir_strcpy(tmpPath, dbv.pszVal); + strncpy_s(tmpPath, dbv.pszVal, _TRUNCATE); if (strncmp(tmpPath, "http://", 7)) PathToAbsolute(dbv.pszVal, tmpPath); @@ -1557,7 +1557,7 @@ void Options::init() } mir_snprintf(dbsName, "%s.%s", proto->getProtocolName(), DBS_CHAT_TEMPLATE); if (!db_get(NULL, ieviewModuleName, dbsName, &dbv)) { - mir_strcpy(tmpPath, dbv.pszVal); + strncpy_s(tmpPath, dbv.pszVal, _TRUNCATE); PathToAbsolute(dbv.pszVal, tmpPath); proto->setChatTemplateFilename(tmpPath); db_free(&dbv); @@ -1572,7 +1572,7 @@ void Options::init() proto->setHistoryFlags(db_get_dw(NULL, ieviewModuleName, dbsName, 16128)); mir_snprintf(dbsName, "%s.%s", proto->getProtocolName(), DBS_HISTORY_BACKGROUND); if (!db_get(NULL, ieviewModuleName, dbsName, &dbv)) { - mir_strcpy(tmpPath, dbv.pszVal); + strncpy_s(tmpPath, dbv.pszVal, _TRUNCATE); if (strncmp(tmpPath, "http://", 7)) PathToAbsolute(dbv.pszVal, tmpPath); @@ -1581,7 +1581,7 @@ void Options::init() } mir_snprintf(dbsName, "%s.%s", proto->getProtocolName(), DBS_HISTORY_CSS); if (!db_get(NULL, ieviewModuleName, dbsName, &dbv)) { - mir_strcpy(tmpPath, dbv.pszVal); + strncpy_s(tmpPath, dbv.pszVal, _TRUNCATE); if (strncmp(tmpPath, "http://", 7)) PathToAbsolute(dbv.pszVal, tmpPath); @@ -1590,7 +1590,7 @@ void Options::init() } mir_snprintf(dbsName, "%s.%s", proto->getProtocolName(), DBS_HISTORY_TEMPLATE); if (!db_get(NULL, ieviewModuleName, dbsName, &dbv)) { - mir_strcpy(tmpPath, dbv.pszVal); + strncpy_s(tmpPath, dbv.pszVal, _TRUNCATE); PathToAbsolute(dbv.pszVal, tmpPath); proto->setHistoryTemplateFilename(tmpPath); db_free(&dbv); @@ -1691,17 +1691,17 @@ void Options::saveProtocolSettings() mir_snprintf(dbsName, "%s.%s", proto->getProtocolName(), DBS_SRMM_FLAGS); db_set_dw(NULL, ieviewModuleName, dbsName, proto->getSRMMFlags()); mir_snprintf(dbsName, "%s.%s", proto->getProtocolName(), DBS_SRMM_BACKGROUND); - mir_strcpy(tmpPath, proto->getSRMMBackgroundFilename()); + strncpy_s(tmpPath, proto->getSRMMBackgroundFilename(), _TRUNCATE); PathToRelative(proto->getSRMMBackgroundFilename(), tmpPath); db_set_s(NULL, ieviewModuleName, dbsName, tmpPath); mir_snprintf(dbsName, "%s.%s", proto->getProtocolName(), DBS_SRMM_CSS); - mir_strcpy(tmpPath, proto->getSRMMCssFilename()); + strncpy_s(tmpPath, proto->getSRMMCssFilename(), _TRUNCATE); PathToRelative(proto->getSRMMCssFilename(), tmpPath); db_set_s(NULL, ieviewModuleName, dbsName, tmpPath); mir_snprintf(dbsName, "%s.%s", proto->getProtocolName(), DBS_SRMM_TEMPLATE); - mir_strcpy(tmpPath, proto->getSRMMTemplateFilename()); + strncpy_s(tmpPath, proto->getSRMMTemplateFilename(), _TRUNCATE); PathToRelative(proto->getSRMMTemplateFilename(), tmpPath); db_set_s(NULL, ieviewModuleName, dbsName, tmpPath); @@ -1713,17 +1713,17 @@ void Options::saveProtocolSettings() mir_snprintf(dbsName, "%s.%s", proto->getProtocolName(), DBS_CHAT_FLAGS); db_set_dw(NULL, ieviewModuleName, dbsName, proto->getChatFlags()); mir_snprintf(dbsName, "%s.%s", proto->getProtocolName(), DBS_CHAT_BACKGROUND); - mir_strcpy(tmpPath, proto->getChatBackgroundFilename()); + strncpy_s(tmpPath, proto->getChatBackgroundFilename(), _TRUNCATE); PathToRelative(proto->getChatBackgroundFilename(), tmpPath); db_set_s(NULL, ieviewModuleName, dbsName, tmpPath); mir_snprintf(dbsName, "%s.%s", proto->getProtocolName(), DBS_CHAT_CSS); - mir_strcpy(tmpPath, proto->getChatCssFilename()); + strncpy_s(tmpPath, proto->getChatCssFilename(), _TRUNCATE); PathToRelative(proto->getChatCssFilename(), tmpPath); db_set_s(NULL, ieviewModuleName, dbsName, tmpPath); mir_snprintf(dbsName, "%s.%s", proto->getProtocolName(), DBS_CHAT_TEMPLATE); - mir_strcpy(tmpPath, proto->getChatTemplateFilename()); + strncpy_s(tmpPath, proto->getChatTemplateFilename(), _TRUNCATE); PathToRelative(proto->getChatTemplateFilename(), tmpPath); db_set_s(NULL, ieviewModuleName, dbsName, tmpPath); @@ -1735,17 +1735,17 @@ void Options::saveProtocolSettings() mir_snprintf(dbsName, "%s.%s", proto->getProtocolName(), DBS_HISTORY_FLAGS); db_set_dw(NULL, ieviewModuleName, dbsName, proto->getHistoryFlags()); mir_snprintf(dbsName, "%s.%s", proto->getProtocolName(), DBS_HISTORY_BACKGROUND); - mir_strcpy(tmpPath, proto->getHistoryBackgroundFilename()); + strncpy_s(tmpPath, proto->getHistoryBackgroundFilename(), _TRUNCATE); PathToRelative(proto->getHistoryBackgroundFilename(), tmpPath); db_set_s(NULL, ieviewModuleName, dbsName, tmpPath); mir_snprintf(dbsName, "%s.%s", proto->getProtocolName(), DBS_HISTORY_CSS); - mir_strcpy(tmpPath, proto->getHistoryCssFilename()); + strncpy_s(tmpPath, proto->getHistoryCssFilename(), _TRUNCATE); PathToRelative(proto->getHistoryCssFilename(), tmpPath); db_set_s(NULL, ieviewModuleName, dbsName, tmpPath); mir_snprintf(dbsName, "%s.%s", proto->getProtocolName(), DBS_HISTORY_TEMPLATE); - mir_strcpy(tmpPath, proto->getHistoryTemplateFilename()); + strncpy_s(tmpPath, proto->getHistoryTemplateFilename(), _TRUNCATE); PathToRelative(proto->getHistoryTemplateFilename(), tmpPath); db_set_s(NULL, ieviewModuleName, dbsName, tmpPath); } diff --git a/plugins/IEView/src/ScriverHTMLBuilder.cpp b/plugins/IEView/src/ScriverHTMLBuilder.cpp index b7538c2cc4..c86c1bce5d 100644 --- a/plugins/IEView/src/ScriverHTMLBuilder.cpp +++ b/plugins/IEView/src/ScriverHTMLBuilder.cpp @@ -112,9 +112,9 @@ void ScriverHTMLBuilder::loadMsgDlgFont(int i, LOGFONTA * lf, COLORREF * colour) lf->lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; mir_snprintf(str, "SRMFont%d", i); if (db_get(NULL, SRMMMOD, str, &dbv)) - mir_strcpy(lf->lfFaceName, "Verdana"); + strncpy_s(lf->lfFaceName, "Verdana", _TRUNCATE); else { - mir_strncpy(lf->lfFaceName, dbv.pszVal, sizeof(lf->lfFaceName)); + strncpy_s(lf->lfFaceName, dbv.pszVal, _TRUNCATE); db_free(&dbv); } } @@ -149,9 +149,9 @@ char* ScriverHTMLBuilder::timestampToString(DWORD dwFlags, time_t check, int mod } else { if (dwFlags & SMF_LOG_USELONGDATE) - mir_strcpy(format, "D"); + strncpy_s(format, "D", _TRUNCATE); else - mir_strcpy(format, "d"); + strncpy_s(format, "d", _TRUNCATE); } } if (mode == 0 || mode == 2) { diff --git a/plugins/IEView/src/TabSRMMHTMLBuilder.cpp b/plugins/IEView/src/TabSRMMHTMLBuilder.cpp index 657e22560a..43201883e4 100644 --- a/plugins/IEView/src/TabSRMMHTMLBuilder.cpp +++ b/plugins/IEView/src/TabSRMMHTMLBuilder.cpp @@ -143,9 +143,9 @@ void TabSRMMHTMLBuilder::loadMsgDlgFont(int i, LOGFONTA * lf, COLORREF * colour) lf->lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; mir_snprintf(str, "Font%d", i); if (db_get(NULL, TABSRMM_FONTMODULE, str, &dbv)) - mir_strcpy(lf->lfFaceName, "Verdana"); + strncpy_s(lf->lfFaceName, "Verdana", _TRUNCATE); else { - mir_strncpy(lf->lfFaceName, dbv.pszVal, sizeof(lf->lfFaceName)); + strncpy_s(lf->lfFaceName, dbv.pszVal, _TRUNCATE); db_free(&dbv); } } @@ -173,12 +173,12 @@ char* TabSRMMHTMLBuilder::timestampToString(DWORD dwFlags, time_t check, int isG if (dwFlags & MWF_LOG_USERELATIVEDATES && check >= today) { szFormat = (dwFlags & MWF_LOG_SHOWSECONDS) ? "s" : "t"; - mir_strcpy(szResult, Translate("Today")); + strncpy_s(szResult, Translate("Today"), _TRUNCATE); mir_strcat(szResult, ", "); } else if (dwFlags & MWF_LOG_USERELATIVEDATES && check > (today - 86400)) { szFormat = (dwFlags & MWF_LOG_SHOWSECONDS) ? "s" : "t"; - mir_strcpy(szResult, Translate("Yesterday")); + strncpy_s(szResult, Translate("Yesterday"), _TRUNCATE); mir_strcat(szResult, ", "); } else { diff --git a/plugins/IEView/src/TemplateHTMLBuilder.cpp b/plugins/IEView/src/TemplateHTMLBuilder.cpp index 95b083c771..9f7ebb07a7 100644 --- a/plugins/IEView/src/TemplateHTMLBuilder.cpp +++ b/plugins/IEView/src/TemplateHTMLBuilder.cpp @@ -57,7 +57,7 @@ char* TemplateHTMLBuilder::getAvatar(MCONTACT hContact, const char *szProto) //wchar_t *ext = wcsrchr(dbv.ptszVal, '.'); if (result == nullptr) { /* relative -> absolute */ - mir_wstrcpy(tmpPath, dbv.ptszVal); + wcsncpy_s(tmpPath, dbv.ptszVal, _TRUNCATE); if (wcsncmp(tmpPath, L"http://", 7)) PathToAbsoluteW(dbv.ptszVal, tmpPath); result = tmpPath; @@ -133,7 +133,7 @@ void TemplateHTMLBuilder::buildHeadTemplate(IEView *view, IEVIEWEVENT *event, Pr char tempBase[1024] = { 0 }; - mir_strcpy(tempBase, "file://"); + strncpy_s(tempBase, "file://", _TRUNCATE); mir_strncat(tempBase, tmpm->getFilename(), _countof(tempBase) - mir_strlen(tempBase)); char *pathrun = tempBase + mir_strlen(tempBase); while ((*pathrun != '\\' && *pathrun != '/') && (pathrun > tempBase)) @@ -296,7 +296,7 @@ void TemplateHTMLBuilder::appendEventTemplate(IEView *view, IEVIEWEVENT *event, TemplateMap *tmpm = getTemplateMap(protoSettings); if (tmpm != nullptr) { - mir_strcpy(tempBase, "file://"); + strncpy_s(tempBase, "file://", _TRUNCATE); mir_strcat(tempBase, tmpm->getFilename()); char* pathrun = nullptr; -- cgit v1.2.3