diff --git a/PowerEditor/src/MISC/Common/Common.cpp b/PowerEditor/src/MISC/Common/Common.cpp index c68758f6..9ce5e087 100644 --- a/PowerEditor/src/MISC/Common/Common.cpp +++ b/PowerEditor/src/MISC/Common/Common.cpp @@ -1219,7 +1219,7 @@ bool deleteFileOrFolder(const generic_string& f2delete) { auto len = f2delete.length(); TCHAR* actionFolder = new TCHAR[len + 2]; - lstrcpy(actionFolder, f2delete.c_str()); + wcscpy_s(actionFolder, len + 2, f2delete.c_str()); actionFolder[len] = 0; actionFolder[len + 1] = 0; diff --git a/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp b/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp index 7eaa3704..ef4cd0d4 100644 --- a/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp +++ b/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp @@ -211,7 +211,7 @@ int PluginsManager::loadPlugin(const TCHAR *pluginFilePath) } TCHAR xmlPath[MAX_PATH]; - lstrcpy(xmlPath, nppParams->getNppPath().c_str()); + wcscpy_s(xmlPath, nppParams->getNppPath().c_str()); PathAppend(xmlPath, TEXT("plugins\\Config")); PathAppend(xmlPath, pi->_moduleName.c_str()); PathRemoveExtension(xmlPath); @@ -220,7 +220,7 @@ int PluginsManager::loadPlugin(const TCHAR *pluginFilePath) if (!PathFileExists(xmlPath)) { lstrcpyn(xmlPath, TEXT("\0"), MAX_PATH ); - lstrcpy(xmlPath, nppParams->getAppDataNppDir() ); + wcscpy_s(xmlPath, nppParams->getAppDataNppDir() ); PathAppend(xmlPath, TEXT("plugins\\Config")); PathAppend(xmlPath, pi->_moduleName.c_str()); PathRemoveExtension( xmlPath ); diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index 76778a35..1615c689 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -2480,11 +2480,12 @@ void Notepad_plus::addHotSpot() hotspotStyle._styleID = static_cast(style_hotspot); _pEditView->execute(SCI_STYLEGETFONT, idStyleMSBunset, reinterpret_cast(fontNameA)); - TCHAR *generic_fontname = new TCHAR[128]; + const size_t generic_fontnameLen = 128; + TCHAR *generic_fontname = new TCHAR[generic_fontnameLen]; WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); const wchar_t * fontNameW = wmc->char2wchar(fontNameA, _nativeLangSpeaker.getLangEncoding()); - lstrcpy(generic_fontname, fontNameW); + wcscpy_s(generic_fontname, generic_fontnameLen, fontNameW); hotspotStyle._fontName = generic_fontname; hotspotStyle._fgColor = static_cast(_pEditView->execute(SCI_STYLEGETFORE, idStyleMSBunset)); @@ -5798,7 +5799,7 @@ void Notepad_plus::launchClipboardHistoryPanel() static TCHAR title[32]; if (title_temp.length() < 32) { - lstrcpy(title, title_temp.c_str()); + wcscpy_s(title, title_temp.c_str()); data.pszName = title; } ::SendMessage(_pPublicInterface->getHSelf(), NPPM_DMMREGASDCKDLG, 0, reinterpret_cast(&data)); @@ -5841,7 +5842,7 @@ void Notepad_plus::launchFileSwitcherPanel() static TCHAR title[32]; if (title_temp.length() < 32) { - lstrcpy(title, title_temp.c_str()); + wcscpy_s(title, title_temp.c_str()); data.pszName = title; } ::SendMessage(_pPublicInterface->getHSelf(), NPPM_DMMREGASDCKDLG, 0, reinterpret_cast(&data)); @@ -5882,7 +5883,7 @@ void Notepad_plus::launchAnsiCharPanel() static TCHAR title[32]; if (title_temp.length() < 32) { - lstrcpy(title, title_temp.c_str()); + wcscpy_s(title, title_temp.c_str()); data.pszName = title; } ::SendMessage(_pPublicInterface->getHSelf(), NPPM_DMMREGASDCKDLG, 0, reinterpret_cast(&data)); @@ -5926,7 +5927,7 @@ void Notepad_plus::launchFileBrowser(const vector & folders) static TCHAR title[32]; if (title_temp.length() < 32) { - lstrcpy(title, title_temp.c_str()); + wcscpy_s(title, title_temp.c_str()); data.pszName = title; } ::SendMessage(_pPublicInterface->getHSelf(), NPPM_DMMREGASDCKDLG, 0, reinterpret_cast(&data)); @@ -5983,7 +5984,7 @@ void Notepad_plus::launchProjectPanel(int cmdID, ProjectPanel ** pProjPanel, int static TCHAR title[32]; if (title_temp.length() < 32) { - lstrcpy(title, title_temp.c_str()); + wcscpy_s(title, title_temp.c_str()); data.pszName = title; } ::SendMessage(_pPublicInterface->getHSelf(), NPPM_DMMREGASDCKDLG, 0, reinterpret_cast(&data)); @@ -6035,7 +6036,7 @@ void Notepad_plus::launchDocMap() static TCHAR title[32]; if (title_temp.length() < 32) { - lstrcpy(title, title_temp.c_str()); + wcscpy_s(title, title_temp.c_str()); data.pszName = title; } ::SendMessage(_pPublicInterface->getHSelf(), NPPM_DMMREGASDCKDLG, 0, reinterpret_cast(&data)); @@ -6076,7 +6077,7 @@ void Notepad_plus::launchFunctionList() static TCHAR title[32]; if (title_temp.length() < 32) { - lstrcpy(title, title_temp.c_str()); + wcscpy_s(title, title_temp.c_str()); data.pszName = title; } diff --git a/PowerEditor/src/NppBigSwitch.cpp b/PowerEditor/src/NppBigSwitch.cpp index 193383d0..ec3fe20e 100644 --- a/PowerEditor/src/NppBigSwitch.cpp +++ b/PowerEditor/src/NppBigSwitch.cpp @@ -688,7 +688,8 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa { TCHAR str[MAX_PATH]; // par defaut : NPPM_GETCURRENTDIRECTORY - TCHAR *fileStr = lstrcpy(str, _pEditView->getCurrentBuffer()->getFullPathName()); + wcscpy_s(str, _pEditView->getCurrentBuffer()->getFullPathName()); + TCHAR* fileStr = str; if (message == NPPM_GETCURRENTDIRECTORY) PathRemoveFileSpec(str); diff --git a/PowerEditor/src/NppCommands.cpp b/PowerEditor/src/NppCommands.cpp index 0ebe2942..b93c0b2f 100644 --- a/PowerEditor/src/NppCommands.cpp +++ b/PowerEditor/src/NppCommands.cpp @@ -402,7 +402,7 @@ void Notepad_plus::command(int id) TCHAR cmd2Exec[CURRENTWORD_MAXLENGTH]; if (id == IDM_EDIT_OPENINFOLDER) { - lstrcpy(cmd2Exec, TEXT("explorer")); + wcscpy_s(cmd2Exec, TEXT("explorer")); } else { diff --git a/PowerEditor/src/NppIO.cpp b/PowerEditor/src/NppIO.cpp index 659cda5b..560aac4c 100644 --- a/PowerEditor/src/NppIO.cpp +++ b/PowerEditor/src/NppIO.cpp @@ -50,7 +50,7 @@ DWORD WINAPI Notepad_plus::monitorFileOnChange(void * params) //The folder to watch : WCHAR folderToMonitor[MAX_PATH]; - lstrcpy(folderToMonitor, fullFileName); + wcscpy_s(folderToMonitor, fullFileName); ::PathRemoveFileSpecW(folderToMonitor); @@ -153,7 +153,7 @@ BufferID Notepad_plus::doOpen(const generic_string& fileName, bool isRecursive, bool isSnapshotMode = backupFileName != NULL && PathFileExists(backupFileName); if (isSnapshotMode && !PathFileExists(longFileName)) // UNTITLED { - lstrcpy(longFileName, fileName.c_str()); + wcscpy_s(longFileName, fileName.c_str()); } diff --git a/PowerEditor/src/NppNotification.cpp b/PowerEditor/src/NppNotification.cpp index 6bfc96e1..6490b536 100644 --- a/PowerEditor/src/NppNotification.cpp +++ b/PowerEditor/src/NppNotification.cpp @@ -882,7 +882,7 @@ BOOL Notepad_plus::notify(SCNotification *notification) if (tipTmp.length() >= 80) return FALSE; - lstrcpy(lpttt->szText, tipTmp.c_str()); + wcscpy_s(lpttt->szText, tipTmp.c_str()); return TRUE; } else if (hWin == _mainDocTab.getHSelf()) @@ -893,7 +893,7 @@ BOOL Notepad_plus::notify(SCNotification *notification) if (tipTmp.length() >= tipMaxLen) return FALSE; - lstrcpy(docTip, tipTmp.c_str()); + wcscpy_s(docTip, tipTmp.c_str()); lpttt->lpszText = docTip; return TRUE; } @@ -905,7 +905,7 @@ BOOL Notepad_plus::notify(SCNotification *notification) if (tipTmp.length() >= tipMaxLen) return FALSE; - lstrcpy(docTip, tipTmp.c_str()); + wcscpy_s(docTip, tipTmp.c_str()); lpttt->lpszText = docTip; return TRUE; } diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index 28cf5293..afd964ba 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -999,7 +999,7 @@ bool NppParameters::load() { generic_string progPath = getSpecialFolderLocation(CSIDL_PROGRAM_FILES); TCHAR nppDirLocation[MAX_PATH]; - lstrcpy(nppDirLocation, _nppPath.c_str()); + wcscpy_s(nppDirLocation, _nppPath.c_str()); ::PathRemoveFileSpec(nppDirLocation); if (progPath == nppDirLocation) @@ -3344,7 +3344,7 @@ void NppParameters::feedUserKeywordList(TiXmlNode *node) temp += TEXT(" 08"); if (kwl[5] != '0') temp += kwl[5]; temp += TEXT(" 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23"); - lstrcpy(_userLangArray[_nbUserLang - 1]->_keywordLists[SCE_USER_KWLIST_DELIMITERS], temp.c_str()); + wcscpy_s(_userLangArray[_nbUserLang - 1]->_keywordLists[SCE_USER_KWLIST_DELIMITERS], temp.c_str()); } else if (!lstrcmp(keywordsName, TEXT("Comment"))) { @@ -3378,7 +3378,7 @@ void NppParameters::feedUserKeywordList(TiXmlNode *node) if (temp[0] == ' ') temp.erase(0, 1); - lstrcpy(_userLangArray[_nbUserLang - 1]->_keywordLists[SCE_USER_KWLIST_COMMENTS], temp.c_str()); + wcscpy_s(_userLangArray[_nbUserLang - 1]->_keywordLists[SCE_USER_KWLIST_COMMENTS], temp.c_str()); } else { @@ -3388,11 +3388,11 @@ void NppParameters::feedUserKeywordList(TiXmlNode *node) id = globalMappper().keywordIdMapper[keywordsName]; if (_tcslen(kwl) < max_char) { - lstrcpy(_userLangArray[_nbUserLang - 1]->_keywordLists[id], kwl); + wcscpy_s(_userLangArray[_nbUserLang - 1]->_keywordLists[id], kwl); } else { - lstrcpy(_userLangArray[_nbUserLang - 1]->_keywordLists[id], TEXT("imported string too long, needs to be < max_char(30720)")); + wcscpy_s(_userLangArray[_nbUserLang - 1]->_keywordLists[id], TEXT("imported string too long, needs to be < max_char(30720)")); } } } @@ -6627,12 +6627,16 @@ void NppParameters::stylerStrOp(bool op) if (op == DUP) { - TCHAR *str = new TCHAR[lstrlen(style._styleDesc) + 1]; - style._styleDesc = lstrcpy(str, style._styleDesc); + const size_t strLen = lstrlen(style._styleDesc) + 1; + TCHAR *str = new TCHAR[strLen]; + wcscpy_s(str, strLen, style._styleDesc); + style._styleDesc = str; if (style._fontName) { - str = new TCHAR[lstrlen(style._fontName) + 1]; - style._fontName = lstrcpy(str, style._fontName); + const size_t strLen2 = lstrlen(style._fontName) + 1; + str = new TCHAR[strLen2]; + wcscpy_s(str, strLen2, style._fontName); + style._fontName = str; } else { diff --git a/PowerEditor/src/Parameters.h b/PowerEditor/src/Parameters.h index ed8c27e4..b21fb084 100644 --- a/PowerEditor/src/Parameters.h +++ b/PowerEditor/src/Parameters.h @@ -1043,7 +1043,7 @@ public: } for (int i = 0 ; i < SCE_USER_KWLIST_TOTAL ; ++i) - lstrcpy(this->_keywordLists[i], ulc._keywordLists[i]); + wcscpy_s(this->_keywordLists[i], ulc._keywordLists[i]); for (int i = 0 ; i < SCE_USER_TOTAL_KEYWORD_GROUPS ; ++i) _isPrefix[i] = ulc._isPrefix[i]; diff --git a/PowerEditor/src/ScitillaComponent/Buffer.cpp b/PowerEditor/src/ScitillaComponent/Buffer.cpp index 79892d3d..83b17df5 100644 --- a/PowerEditor/src/ScitillaComponent/Buffer.cpp +++ b/PowerEditor/src/ScitillaComponent/Buffer.cpp @@ -594,7 +594,7 @@ BufferID FileManager::loadFile(const TCHAR * filename, Document doc, int encodin bool isSnapshotMode = backupFileName != NULL && PathFileExists(backupFileName); if (isSnapshotMode && !PathFileExists(fullpath)) // if backup mode and fullpath doesn't exist, we guess is UNTITLED { - lstrcpy(fullpath, filename); // we restore fullpath with filename, in our case is "new #" + wcscpy_s(fullpath, MAX_PATH, filename); // we restore fullpath with filename, in our case is "new #" } Utf8_16_Read UnicodeConvertor; //declare here so we can get information after loading is done @@ -1471,8 +1471,10 @@ int FileManager::getFileNameFromBuffer(BufferID id, TCHAR * fn2copy) return -1; Buffer* buf = getBufferByID(id); + if (fn2copy) lstrcpy(fn2copy, buf->getFullPathName()); + return lstrlen(buf->getFullPathName()); } diff --git a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp index c7fe3d6a..d10cb4e3 100644 --- a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp +++ b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp @@ -1496,7 +1496,7 @@ bool FindReplaceDlg::processFindNext(const TCHAR *txt2find, const FindOption *op int stringSizeFind = lstrlen(txt2find); TCHAR *pText = new TCHAR[stringSizeFind + 1]; - lstrcpy(pText, txt2find); + wcscpy_s(pText, stringSizeFind + 1, txt2find); if (pOptions->_searchType == FindExtended) { stringSizeFind = Searching::convertExtendedToString(txt2find, pText, stringSizeFind); @@ -1871,13 +1871,13 @@ int FindReplaceDlg::processRange(ProcessOperation op, FindReplaceInfo & findRepl generic_string str2Search = getTextFromCombo(hFindCombo); stringSizeFind = str2Search.length(); pTextFind = new TCHAR[stringSizeFind + 1]; - lstrcpy(pTextFind, str2Search.c_str()); + wcscpy_s(pTextFind, stringSizeFind + 1, str2Search.c_str()); } else { stringSizeFind = lstrlen(findReplaceInfo._txt2find); pTextFind = new TCHAR[stringSizeFind + 1]; - lstrcpy(pTextFind, findReplaceInfo._txt2find); + wcscpy_s(pTextFind, stringSizeFind + 1, findReplaceInfo._txt2find); } if (!pTextFind[0]) @@ -1895,13 +1895,13 @@ int FindReplaceDlg::processRange(ProcessOperation op, FindReplaceInfo & findRepl generic_string str2Replace = getTextFromCombo(hReplaceCombo); stringSizeReplace = str2Replace.length(); pTextReplace = new TCHAR[stringSizeReplace + 1]; - lstrcpy(pTextReplace, str2Replace.c_str()); + wcscpy_s(pTextReplace, stringSizeReplace + 1, str2Replace.c_str()); } else { stringSizeReplace = lstrlen(findReplaceInfo._txt2replace); pTextReplace = new TCHAR[stringSizeReplace + 1]; - lstrcpy(pTextReplace, findReplaceInfo._txt2replace); + wcscpy_s(pTextReplace, stringSizeReplace + 1, findReplaceInfo._txt2replace); } } diff --git a/PowerEditor/src/ScitillaComponent/FunctionCallTip.cpp b/PowerEditor/src/ScitillaComponent/FunctionCallTip.cpp index 1a07b8aa..e301de36 100644 --- a/PowerEditor/src/ScitillaComponent/FunctionCallTip.cpp +++ b/PowerEditor/src/ScitillaComponent/FunctionCallTip.cpp @@ -280,7 +280,7 @@ bool FunctionCallTip::getCursorFunction() delete [] _funcName; } _funcName = new TCHAR[funcToken.length+1]; - lstrcpy(_funcName, funcToken.token); + wcscpy_s(_funcName, funcToken.length+1, funcToken.token); res = loadFunction(); } else diff --git a/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp b/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp index 46586a1d..e32c4024 100644 --- a/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp +++ b/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp @@ -2120,7 +2120,7 @@ TCHAR * ScintillaEditView::getGenericWordOnCaretPos(TCHAR * txt, int size) getWordOnCaretPos(txtA, size); const TCHAR * txtW = wmc->char2wchar(txtA, cp); - lstrcpy(txt, txtW); + wcscpy_s(txt, size, txtW); delete [] txtA; return txt; } @@ -2151,7 +2151,7 @@ TCHAR * ScintillaEditView::getGenericSelectedText(TCHAR * txt, int size, bool ex getSelectedText(txtA, size, expand); const TCHAR * txtW = wmc->char2wchar(txtA, cp); - lstrcpy(txt, txtW); + wcscpy_s(txt, size, txtW); delete [] txtA; return txt; } @@ -2824,7 +2824,7 @@ TCHAR * int2str(TCHAR *str, int strLen, int number, int base, int nbChiffre, boo for ( ; *j != '\0' ; ++j) if (*j == '1') break; - lstrcpy(str, j); + wcscpy_s(str, strLen, j); } else { diff --git a/PowerEditor/src/ScitillaComponent/UserDefineDialog.cpp b/PowerEditor/src/ScitillaComponent/UserDefineDialog.cpp index 38b769c9..717cbf5d 100644 --- a/PowerEditor/src/ScitillaComponent/UserDefineDialog.cpp +++ b/PowerEditor/src/ScitillaComponent/UserDefineDialog.cpp @@ -524,7 +524,7 @@ void CommentStyleDialog::setKeywords2List(int id) convertTo(newList, max_char, buffer, intBuffer); } - lstrcpy(_pUserLang->_keywordLists[index], newList); + wcscpy_s(_pUserLang->_keywordLists[index], newList); } } @@ -836,7 +836,7 @@ void SymbolsStyleDialog::setKeywords2List(int id) convertTo(newList, max_char, buffer, intBuffer); } - lstrcpy(_pUserLang->_keywordLists[SCE_USER_KWLIST_DELIMITERS], newList); + wcscpy_s(_pUserLang->_keywordLists[SCE_USER_KWLIST_DELIMITERS], newList); break; } default : diff --git a/PowerEditor/src/TinyXml/tinyxml.cpp b/PowerEditor/src/TinyXml/tinyxml.cpp index 25ef432e..d3582c25 100644 --- a/PowerEditor/src/TinyXml/tinyxml.cpp +++ b/PowerEditor/src/TinyXml/tinyxml.cpp @@ -105,10 +105,11 @@ void TiXmlBase::PutString( const TIXML_STRING& str, TIXML_STRING* outString ) // <-- Strange class for a bug fix. Search for STL_STRING_BUG TiXmlBase::StringToBuffer::StringToBuffer( const TIXML_STRING& str ) { - buffer = new TCHAR[ str.length()+1 ]; - if ( buffer ) + const size_t strLen = str.length() + 1; + buffer = new TCHAR[strLen]; + if (buffer) { - lstrcpy( buffer, str.c_str() ); + wcscpy_s(buffer, strLen, str.c_str()); } } diff --git a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp index 8651097d..8acc694a 100644 --- a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp +++ b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp @@ -643,7 +643,7 @@ void WordStyleDlg::switchToTheme() if (_isThemeDirty) { TCHAR themeFileName[MAX_PATH]; - lstrcpy(themeFileName, prevThemeName.c_str()); + wcscpy_s(themeFileName, prevThemeName.c_str()); PathStripPath(themeFileName); PathRemoveExtension(themeFileName); int mb_response = diff --git a/PowerEditor/src/WinControls/FileBrowser/fileBrowser.cpp b/PowerEditor/src/WinControls/FileBrowser/fileBrowser.cpp index 08924291..002ec614 100644 --- a/PowerEditor/src/WinControls/FileBrowser/fileBrowser.cpp +++ b/PowerEditor/src/WinControls/FileBrowser/fileBrowser.cpp @@ -910,7 +910,7 @@ void FileBrowser::addRootFolder(generic_string rootFolderPath) TCHAR *label = ::PathFindFileName(rootFolderPath.c_str()); TCHAR rootLabel[MAX_PATH]; - lstrcpy(rootLabel, label); + wcscpy_s(rootLabel, label); size_t len = lstrlen(rootLabel); if (rootLabel[len - 1] == '\\') rootLabel[len - 1] = '\0'; @@ -929,7 +929,7 @@ HTREEITEM FileBrowser::createFolderItemsFromDirStruct(HTREEITEM hParentItem, con if (directoryStructure._parent == nullptr && hParentItem == nullptr) { TCHAR rootPath[MAX_PATH]; - lstrcpy(rootPath, directoryStructure._rootPath.c_str()); + wcscpy_s(rootPath, directoryStructure._rootPath.c_str()); size_t len = lstrlen(rootPath); if (rootPath[len - 1] == '\\') rootPath[len - 1] = '\0'; diff --git a/PowerEditor/src/WinControls/FunctionList/functionListPanel.cpp b/PowerEditor/src/WinControls/FunctionList/functionListPanel.cpp index 17810e35..91b5e59a 100644 --- a/PowerEditor/src/WinControls/FunctionList/functionListPanel.cpp +++ b/PowerEditor/src/WinControls/FunctionList/functionListPanel.cpp @@ -513,11 +513,11 @@ void FunctionListPanel::notified(LPNMHDR notification) if (notification->idFrom == IDC_SORTBUTTON_FUNCLIST) { - lstrcpy(lpttt->szText, _sortTipStr.c_str()); + wcscpy_s(lpttt->szText, _sortTipStr.c_str()); } else if (notification->idFrom == IDC_RELOADBUTTON_FUNCLIST) { - lstrcpy(lpttt->szText, _reloadTipStr.c_str()); + wcscpy_s(lpttt->szText, _reloadTipStr.c_str()); } } else if (notification->hwndFrom == _treeView.getHSelf() || notification->hwndFrom == this->_treeViewSearchResult.getHSelf()) diff --git a/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.cpp b/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.cpp index 7290be1b..666cd827 100644 --- a/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.cpp +++ b/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.cpp @@ -146,11 +146,13 @@ int FileDialog::setExtsFilter(const TCHAR *extText, const TCHAR *exts) // Append new filter TCHAR *pFileExt = _fileExt + _nbCharFileExt; - lstrcpy(pFileExt, extFilter.c_str()); + int curLen = nbCharNewFileExt - _nbCharFileExt; + wcscpy_s(pFileExt, curLen, extFilter.c_str()); _nbCharFileExt += static_cast(extFilter.length()) + 1; pFileExt = _fileExt + _nbCharFileExt; - lstrcpy(pFileExt, exts); + curLen -= _nbCharFileExt; + wcscpy_s(pFileExt, curLen, exts); _nbCharFileExt += lstrlen(exts) + 1; // Set file dialog pointer @@ -240,7 +242,7 @@ stringVector * FileDialog::doOpenMultiFilesDlg() } else { - lstrcpy(fn, _fileName); + wcscpy_s(fn, _fileName); if (fn[lstrlen(fn) - 1] != '\\') lstrcat(fn, TEXT("\\")); } diff --git a/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.h b/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.h index 307827aa..fe223450 100644 --- a/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.h +++ b/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.h @@ -49,7 +49,7 @@ public: void setExtFilter(const TCHAR *, const TCHAR *, ...); int setExtsFilter(const TCHAR *extText, const TCHAR *exts); - void setDefFileName(const TCHAR *fn){lstrcpy(_fileName, fn);} + void setDefFileName(const TCHAR *fn){ wcscpy_s(_fileName, fn);} TCHAR * doSaveDlg(); stringVector * doOpenMultiFilesDlg(); diff --git a/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.cpp b/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.cpp index 6ef022da..24853aa4 100644 --- a/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.cpp +++ b/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.cpp @@ -809,7 +809,7 @@ bool PluginsAdminDlg::loadFromPluginInfos() // user file name (without ext. to find whole info in available list TCHAR fnNoExt[MAX_PATH]; - lstrcpy(fnNoExt, i._fileName.c_str()); + wcscpy_s(fnNoExt, i._fileName.c_str()); ::PathRemoveExtension(fnNoExt); int listIndex; diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp index f18eed88..bcd33ef5 100644 --- a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp +++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp @@ -1367,7 +1367,7 @@ INT_PTR CALLBACK DefaultDirectoryDlg::run_dlgProc(UINT message, WPARAM wParam, L { TCHAR inputDir[MAX_PATH]; ::SendDlgItemMessage(_hSelf, IDC_OPENSAVEDIR_ALWAYSON_EDIT, WM_GETTEXT, MAX_PATH, reinterpret_cast(inputDir)); - lstrcpy(nppGUI._defaultDir, inputDir); + wcscpy_s(nppGUI._defaultDir, inputDir); ::ExpandEnvironmentStrings(nppGUI._defaultDir, nppGUI._defaultDirExp, _countof(nppGUI._defaultDirExp)); pNppParam->setWorkingDir(nppGUI._defaultDirExp); return TRUE; diff --git a/PowerEditor/src/WinControls/ProjectPanel/ProjectPanel.cpp b/PowerEditor/src/WinControls/ProjectPanel/ProjectPanel.cpp index 7c6b8e5a..63387b5b 100644 --- a/PowerEditor/src/WinControls/ProjectPanel/ProjectPanel.cpp +++ b/PowerEditor/src/WinControls/ProjectPanel/ProjectPanel.cpp @@ -474,7 +474,7 @@ void ProjectPanel::buildProjectXml(TiXmlNode *node, HTREEITEM hItem, const TCHAR generic_string ProjectPanel::getRelativePath(const generic_string & filePath, const TCHAR *workSpaceFileName) { TCHAR wsfn[MAX_PATH]; - lstrcpy(wsfn, workSpaceFileName); + wcscpy_s(wsfn, workSpaceFileName); ::PathRemoveFileSpec(wsfn); size_t pos_found = filePath.find(wsfn); @@ -521,7 +521,7 @@ generic_string ProjectPanel::getAbsoluteFilePath(const TCHAR * relativePath) return relativePath; TCHAR absolutePath[MAX_PATH]; - lstrcpy(absolutePath, _workSpaceFilePath.c_str()); + wcscpy_s(absolutePath, _workSpaceFilePath.c_str()); ::PathRemoveFileSpec(absolutePath); ::PathAppend(absolutePath, relativePath); return absolutePath; @@ -1092,7 +1092,7 @@ void ProjectPanel::popupMenuCmd(int cmdID) *fn = newValue; TCHAR *strValueLabel = ::PathFindFileName(fn->c_str()); - lstrcpy(textBuffer, strValueLabel); + wcscpy_s(textBuffer, strValueLabel); int iImage = ::PathFileExists(fn->c_str())?INDEX_LEAF:INDEX_LEAF_INVALID; tvItem.iImage = tvItem.iSelectedImage = iImage; SendMessage(_treeView.getHSelf(), TVM_SETITEM, 0, reinterpret_cast(&tvItem)); @@ -1215,7 +1215,7 @@ void ProjectPanel::addFilesFromDirectory(HTREEITEM hTreeItem) if (_selDirOfFilesFromDirDlg == TEXT("") && _workSpaceFilePath != TEXT("")) { TCHAR dir[MAX_PATH]; - lstrcpy(dir, _workSpaceFilePath.c_str()); + wcscpy_s(dir, _workSpaceFilePath.c_str()); ::PathRemoveFileSpec(dir); _selDirOfFilesFromDirDlg = dir; } diff --git a/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.cpp b/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.cpp index 7173172f..37794fdf 100644 --- a/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.cpp +++ b/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.cpp @@ -181,13 +181,13 @@ HINSTANCE Command::run(HWND hWnd) extractArgs(cmdPure, args, _cmdLine.c_str()); int nbTchar = ::ExpandEnvironmentStrings(cmdPure, cmdIntermediate, MAX_PATH); if (!nbTchar) - lstrcpy(cmdIntermediate, cmdPure); + wcscpy_s(cmdIntermediate, cmdPure); else if (nbTchar >= MAX_PATH) cmdIntermediate[MAX_PATH-1] = '\0'; nbTchar = ::ExpandEnvironmentStrings(args, argsIntermediate, argsIntermediateLen); if (!nbTchar) - lstrcpy(argsIntermediate, args); + wcscpy_s(argsIntermediate, args); else if (nbTchar >= argsIntermediateLen) argsIntermediate[argsIntermediateLen-1] = '\0'; diff --git a/PowerEditor/src/WinControls/TrayIcon/trayIconControler.cpp b/PowerEditor/src/WinControls/TrayIcon/trayIconControler.cpp index 4f167acd..61c1cdc8 100644 --- a/PowerEditor/src/WinControls/TrayIcon/trayIconControler.cpp +++ b/PowerEditor/src/WinControls/TrayIcon/trayIconControler.cpp @@ -36,7 +36,7 @@ trayIconControler::trayIconControler(HWND hwnd, UINT uID, UINT uCBMsg, HICON hic _nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP; _nid.uCallbackMessage = uCBMsg; _nid.hIcon = hicon; - lstrcpy(_nid.szTip, tip); + wcscpy_s(_nid.szTip, tip); ::RegisterWindowMessage(TEXT("TaskbarCreated")); _isIconShowed = false; diff --git a/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcherListView.cpp b/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcherListView.cpp index 1e17ecad..e0467797 100644 --- a/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcherListView.cpp +++ b/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcherListView.cpp @@ -153,7 +153,7 @@ void VerticalFileSwitcherListView::initList() TaskLstFnStatus *tl = new TaskLstFnStatus(fileNameStatus._iView, fileNameStatus._docIndex, fileNameStatus._fn, fileNameStatus._status, (void *)fileNameStatus._bufID); TCHAR fn[MAX_PATH]; - lstrcpy(fn, ::PathFindFileName(fileNameStatus._fn.c_str())); + wcscpy_s(fn, ::PathFindFileName(fileNameStatus._fn.c_str())); if (isExtColumn) { @@ -213,7 +213,7 @@ void VerticalFileSwitcherListView::setItemIconStatus(BufferID bufferID) Buffer *buf = static_cast(bufferID); TCHAR fn[MAX_PATH]; - lstrcpy(fn, ::PathFindFileName(buf->getFileName())); + wcscpy_s(fn, ::PathFindFileName(buf->getFileName())); bool isExtColumn = !(NppParameters::getInstance())->getNppGUI()._fileSwitcherWithoutExtColumn; if (isExtColumn) { @@ -290,7 +290,7 @@ int VerticalFileSwitcherListView::add(BufferID bufferID, int iView) TaskLstFnStatus *tl = new TaskLstFnStatus(iView, 0, buf->getFullPathName(), 0, (void *)bufferID); TCHAR fn[MAX_PATH]; - lstrcpy(fn, ::PathFindFileName(fileName)); + wcscpy_s(fn, ::PathFindFileName(fileName)); bool isExtColumn = !(NppParameters::getInstance())->getNppGUI()._fileSwitcherWithoutExtColumn; if (isExtColumn) {