[EU-FOSSA] Replace lstrcat by wcscat_s to avoid crash

This commit is contained in:
Don HO 2019-02-22 12:57:58 +01:00
parent 70cd3e5ea6
commit bd7816755c
10 changed files with 33 additions and 34 deletions

View File

@ -54,7 +54,7 @@ bool MiniDumper::writeDump(EXCEPTION_POINTERS * pExceptionInfo)
{
::GetModuleFileName(NULL, szDumpPath, MAX_PATH);
::PathRemoveFileSpec(szDumpPath);
lstrcat(szDumpPath, TEXT("\\NppDump.dmp"));
wcscat_s(szDumpPath, TEXT("\\NppDump.dmp"));
// ask the user if they want to save a dump file
int msgret = ::MessageBox(NULL, TEXT("Do you want to save a dump file?\r\nDoing so can aid in developing Notepad++."), msgTitle, MB_YESNO);

View File

@ -365,7 +365,7 @@ bool RegExtDlg::deleteExts(const TCHAR *ext2Delete)
if ((nbValue <= 1) && (!nbSubkey))
{
TCHAR subKey[32] = TEXT("\\");
lstrcat(subKey, ext2Delete);
wcscat_s(subKey, ext2Delete);
::RegDeleteKey(HKEY_CLASSES_ROOT, subKey);
}
else
@ -411,8 +411,9 @@ void RegExtDlg::writeNppPath()
TCHAR nppPath[MAX_PATH];
::GetModuleFileName(_hInst, nppPath, MAX_PATH);
TCHAR nppPathParam[MAX_PATH] = TEXT("\"");
lstrcat(lstrcat(nppPathParam, nppPath), TEXT("\" \"%1\""));
TCHAR nppPathParam[MAX_PATH] = TEXT("\"");
wcscat_s(nppPathParam, nppPath);
wcscat_s(nppPathParam, TEXT("\" \"%1\""));
::RegSetValueEx(hKey, nullptr, 0, REG_SZ, (LPBYTE)nppPathParam, (lstrlen(nppPathParam)+1)*sizeof(TCHAR));
}
@ -432,7 +433,8 @@ void RegExtDlg::writeNppPath()
::GetModuleFileName(_hInst, nppPath, MAX_PATH);
TCHAR nppPathParam[MAX_PATH] = TEXT("\"");
lstrcat(lstrcat(nppPathParam, nppPath), TEXT("\",0"));
wcscat_s(nppPathParam, nppPath);
wcscat_s(nppPathParam, TEXT("\",0"));
::RegSetValueEx(hKey, nullptr, 0, REG_SZ, (LPBYTE)nppPathParam, (lstrlen(nppPathParam)+1)*sizeof(TCHAR));
}

View File

@ -768,9 +768,9 @@ bool AutoCompletion::setLanguage(LangType language) {
TCHAR path[MAX_PATH];
::GetModuleFileName(NULL, path, MAX_PATH);
PathRemoveFileSpec(path);
lstrcat(path, TEXT("\\autoCompletion\\"));
lstrcat(path, getApiFileName());
lstrcat(path, TEXT(".xml"));
wcscat_s(path, TEXT("\\autoCompletion\\"));
wcscat_s(path, getApiFileName());
wcscat_s(path, TEXT(".xml"));
if (_pXmlFile)
delete _pXmlFile;

View File

@ -210,7 +210,6 @@ void TiXmlStringA::append( const char * suffix )
// strcpy (new_string, cstring);
// append the suffix. It does exist, otherwize we wouldn't be expanding
// strcat (new_string, suffix);
memcpy (new_string + length (),
suffix,
strlen (suffix) + 1);
@ -226,7 +225,6 @@ void TiXmlStringA::append( const char * suffix )
else
{
// we know we can safely append the new string
// strcat (cstring, suffix);
memcpy (cstring + length (),
suffix,
strlen (suffix) + 1);

View File

@ -201,7 +201,6 @@ void TiXmlString::append( const TCHAR * suffix )
memcpy (new_string, cstring, 1 + length ());
// append the suffix. It does exist, otherwize we wouldn't be expanding
// lstrcat (new_string, suffix);
memcpy (new_string + length (),
suffix,
lstrlen (suffix) + 1);
@ -217,7 +216,6 @@ void TiXmlString::append( const TCHAR * suffix )
else
{
// we know we can safely append the new generic_string
// lstrcat (cstring, suffix);
memcpy (cstring + length (),
suffix,
lstrlen (suffix) + 1);

View File

@ -744,11 +744,11 @@ void WordStyleDlg::setVisualFromStyleList()
if (lbTextLen > styleNameLen)
return;
::SendDlgItemMessage(_hSelf, IDC_STYLES_LIST, LB_GETTEXT, i, reinterpret_cast<LPARAM>(styleName));
lstrcat(lstrcat(str, TEXT(" : ")), styleName);
wcscat_s(str, TEXT(" : "));
wcscat_s(str, styleName);
// PAD for fix a display glitch
lstrcat(str, TEXT(" "));
wcscat_s(str, TEXT(" "));
colourHooker.setColour(c);
::SetWindowText(_hStyleInfoStaticText, str);

View File

@ -1186,8 +1186,8 @@ void DisplayEditString(HWND hWnd,int SI, const TCHAR* tstring)
if(lstrlen(BGHS[SI].editstring)<=300)
{
lstrcat(BGHS[SI].editstring,tstring);
lstrcpy(BGHS[SI].editstringdisplay,BGHS[SI].editstring);
wcscat_s(BGHS[SI].editstring,tstring);
wcscat_s(BGHS[SI].editstringdisplay,BGHS[SI].editstring);
}
else
{
@ -1577,16 +1577,16 @@ LRESULT CALLBACK GridProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
//protecting or unprotecting a cell that isn't in the list
//add it as blank;
lstrcat(buffer, TEXT("|"));
wcscat_s(buffer, TEXT("|"));
if((BOOL)lParam)
{
lstrcat(buffer, TEXT("PA"));
wcscat_s(buffer, TEXT("PA"));
}
else
{
lstrcat(buffer, TEXT("UA"));
wcscat_s(buffer, TEXT("UA"));
}
lstrcat(buffer, TEXT("|"));
wcscat_s(buffer, TEXT("|"));
SendMessage(BGHS[SelfIndex].hlist1, LB_ADDSTRING, FindResult, reinterpret_cast<LPARAM>(buffer));
}
@ -1653,20 +1653,20 @@ LRESULT CALLBACK GridProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
}
//now add it
lstrcat(buffer, TEXT("|"));
lstrcat(buffer,BGHS[SelfIndex].protect);
wcscat_s(buffer, TEXT("|"));
wcscat_s(buffer,BGHS[SelfIndex].protect);
//determine data type (text,numeric, or boolean)(1,2,3)
//iDataType=DetermineDataType((TCHAR*)lParam);
iDataType = 1;
if(iDataType==1){lstrcat(buffer, TEXT("A"));}
if(iDataType==2){lstrcat(buffer, TEXT("N"));}
if(iDataType==3){lstrcat(buffer, TEXT("T"));}
if(iDataType==4){lstrcat(buffer, TEXT("F"));}
if(iDataType==5){lstrcat(buffer, TEXT("G"));}
if(iDataType==1){ wcscat_s(buffer, TEXT("A"));}
if(iDataType==2){ wcscat_s(buffer, TEXT("N"));}
if(iDataType==3){ wcscat_s(buffer, TEXT("T"));}
if(iDataType==4){ wcscat_s(buffer, TEXT("F"));}
if(iDataType==5){ wcscat_s(buffer, TEXT("G"));}
lstrcat(buffer, TEXT("|"));
lstrcat(buffer, (TCHAR*)lParam);
wcscat_s(buffer, TEXT("|"));
wcscat_s(buffer, (TCHAR*)lParam);
FindResult = static_cast<int32_t>(SendMessage(BGHS[SelfIndex].hlist1, LB_ADDSTRING, 0, reinterpret_cast<LPARAM>(buffer)));
if(FindResult==LB_ERR)

View File

@ -244,7 +244,7 @@ stringVector * FileDialog::doOpenMultiFilesDlg()
{
wcscpy_s(fn, _fileName);
if (fn[lstrlen(fn) - 1] != '\\')
lstrcat(fn, TEXT("\\"));
wcscat_s(fn, TEXT("\\"));
}
int term = lstrlen(fn);
@ -252,7 +252,7 @@ stringVector * FileDialog::doOpenMultiFilesDlg()
while (*pFn)
{
fn[term] = '\0';
lstrcat(fn, pFn);
wcscat_s(fn, pFn);
_fileNames.push_back(generic_string(fn));
pFn += lstrlen(pFn) + 1;
}

View File

@ -336,7 +336,7 @@ INT_PTR CALLBACK WindowsDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lPa
{
len += lstrlen(readonlyString);
if (len <= pLvdi->item.cchTextMax)
lstrcat(pLvdi->item.pszText, readonlyString);
wcscat_s(pLvdi->item.pszText, pLvdi->item.cchTextMax, readonlyString);
}
}
else if (pLvdi->item.iSubItem == 1) // directory

View File

@ -542,7 +542,8 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int)
TCHAR str[50] = TEXT("God Damned Exception : ");
TCHAR code[10];
wsprintf(code, TEXT("%d"), i);
::MessageBox(Notepad_plus_Window::gNppHWND, lstrcat(str, code), TEXT("Int Exception"), MB_OK);
wcscat_s(str, code);
::MessageBox(Notepad_plus_Window::gNppHWND, str, TEXT("Int Exception"), MB_OK);
doException(notepad_plus_plus);
}
catch (std::runtime_error & ex)