[EURO-FOSSA] Fix stack buffer overflow on strcpy
This commit is contained in:
parent
494b4bc0db
commit
ea1fd44ff0
@ -821,110 +821,111 @@ void NativeLangSpeaker::changePrefereceDlgLang(PreferenceDlg & preference)
|
||||
changeDlgLang(preference.getHSelf(), "Preference");
|
||||
|
||||
WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance();
|
||||
char titre[128];
|
||||
changeDlgLang(preference._barsDlg.getHSelf(), "Global", titre);
|
||||
const size_t titreMaxSize = 128;
|
||||
char titre[titreMaxSize];
|
||||
changeDlgLang(preference._barsDlg.getHSelf(), "Global", titre, titreMaxSize);
|
||||
if (titre[0] != '\0')
|
||||
{
|
||||
const wchar_t *nameW = wmc->char2wchar(titre, _nativeLangEncoding);
|
||||
preference.renameDialogTitle(TEXT("Global"), nameW);
|
||||
}
|
||||
changeDlgLang(preference._marginsDlg.getHSelf(), "Scintillas", titre);
|
||||
changeDlgLang(preference._marginsDlg.getHSelf(), "Scintillas", titre, titreMaxSize);
|
||||
if (titre[0] != '\0')
|
||||
{
|
||||
const wchar_t *nameW = wmc->char2wchar(titre, _nativeLangEncoding);
|
||||
preference.renameDialogTitle(TEXT("Scintillas"), nameW);
|
||||
}
|
||||
|
||||
changeDlgLang(preference._defaultNewDocDlg.getHSelf(), "NewDoc", titre);
|
||||
changeDlgLang(preference._defaultNewDocDlg.getHSelf(), "NewDoc", titre, titreMaxSize);
|
||||
if (titre[0] != '\0')
|
||||
{
|
||||
const wchar_t *nameW = wmc->char2wchar(titre, _nativeLangEncoding);
|
||||
preference.renameDialogTitle(TEXT("NewDoc"), nameW);
|
||||
}
|
||||
|
||||
changeDlgLang(preference._defaultDirectoryDlg.getHSelf(), "DefaultDir", titre);
|
||||
changeDlgLang(preference._defaultDirectoryDlg.getHSelf(), "DefaultDir", titre, titreMaxSize);
|
||||
if (titre[0] != '\0')
|
||||
{
|
||||
const wchar_t *nameW = wmc->char2wchar(titre, _nativeLangEncoding);
|
||||
preference.renameDialogTitle(TEXT("DefaultDir"), nameW);
|
||||
}
|
||||
|
||||
changeDlgLang(preference._recentFilesHistoryDlg.getHSelf(), "RecentFilesHistory", titre);
|
||||
changeDlgLang(preference._recentFilesHistoryDlg.getHSelf(), "RecentFilesHistory", titre, titreMaxSize);
|
||||
if (titre[0] != '\0')
|
||||
{
|
||||
const wchar_t *nameW = wmc->char2wchar(titre, _nativeLangEncoding);
|
||||
preference.renameDialogTitle(TEXT("RecentFilesHistory"), nameW);
|
||||
}
|
||||
|
||||
changeDlgLang(preference._fileAssocDlg.getHSelf(), "FileAssoc", titre);
|
||||
changeDlgLang(preference._fileAssocDlg.getHSelf(), "FileAssoc", titre, titreMaxSize);
|
||||
if (titre[0] != '\0')
|
||||
{
|
||||
const wchar_t *nameW = wmc->char2wchar(titre, _nativeLangEncoding);
|
||||
preference.renameDialogTitle(TEXT("FileAssoc"), nameW);
|
||||
}
|
||||
|
||||
changeDlgLang(preference._langMenuDlg.getHSelf(), "Language", titre);
|
||||
changeDlgLang(preference._langMenuDlg.getHSelf(), "Language", titre, titreMaxSize);
|
||||
if (titre[0] != '\0')
|
||||
{
|
||||
const wchar_t *nameW = wmc->char2wchar(titre, _nativeLangEncoding);
|
||||
preference.renameDialogTitle(TEXT("Language"), nameW);
|
||||
}
|
||||
|
||||
changeDlgLang(preference._highlighting.getHSelf(), "Highlighting", titre);
|
||||
changeDlgLang(preference._highlighting.getHSelf(), "Highlighting", titre, titreMaxSize);
|
||||
if (titre[0] != '\0')
|
||||
{
|
||||
const wchar_t *nameW = wmc->char2wchar(titre, _nativeLangEncoding);
|
||||
preference.renameDialogTitle(TEXT("Highlighting"), nameW);
|
||||
}
|
||||
|
||||
changeDlgLang(preference._printSettingsDlg.getHSelf(), "Print", titre);
|
||||
changeDlgLang(preference._printSettingsDlg.getHSelf(), "Print", titre, titreMaxSize);
|
||||
if (titre[0] != '\0')
|
||||
{
|
||||
const wchar_t *nameW = wmc->char2wchar(titre, _nativeLangEncoding);
|
||||
preference.renameDialogTitle(TEXT("Print"), nameW);
|
||||
}
|
||||
changeDlgLang(preference._settingsDlg.getHSelf(), "MISC", titre);
|
||||
changeDlgLang(preference._settingsDlg.getHSelf(), "MISC", titre, titreMaxSize);
|
||||
if (titre[0] != '\0')
|
||||
{
|
||||
const wchar_t *nameW = wmc->char2wchar(titre, _nativeLangEncoding);
|
||||
preference.renameDialogTitle(TEXT("MISC"), nameW);
|
||||
}
|
||||
changeDlgLang(preference._backupDlg.getHSelf(), "Backup", titre);
|
||||
changeDlgLang(preference._backupDlg.getHSelf(), "Backup", titre, titreMaxSize);
|
||||
if (titre[0] != '\0')
|
||||
{
|
||||
const wchar_t *nameW = wmc->char2wchar(titre, _nativeLangEncoding);
|
||||
preference.renameDialogTitle(TEXT("Backup"), nameW);
|
||||
}
|
||||
|
||||
changeDlgLang(preference._autoCompletionDlg.getHSelf(), "AutoCompletion", titre);
|
||||
changeDlgLang(preference._autoCompletionDlg.getHSelf(), "AutoCompletion", titre, titreMaxSize);
|
||||
if (titre[0] != '\0')
|
||||
{
|
||||
const wchar_t *nameW = wmc->char2wchar(titre, _nativeLangEncoding);
|
||||
preference.renameDialogTitle(TEXT("AutoCompletion"), nameW);
|
||||
}
|
||||
|
||||
changeDlgLang(preference._multiInstDlg.getHSelf(), "MultiInstance", titre);
|
||||
changeDlgLang(preference._multiInstDlg.getHSelf(), "MultiInstance", titre, titreMaxSize);
|
||||
if (titre[0] != '\0')
|
||||
{
|
||||
const wchar_t *nameW = wmc->char2wchar(titre, _nativeLangEncoding);
|
||||
preference.renameDialogTitle(TEXT("MultiInstance"), nameW);
|
||||
}
|
||||
|
||||
changeDlgLang(preference._delimiterSettingsDlg.getHSelf(), "Delimiter", titre);
|
||||
changeDlgLang(preference._delimiterSettingsDlg.getHSelf(), "Delimiter", titre, titreMaxSize);
|
||||
if (titre[0] != '\0')
|
||||
{
|
||||
const wchar_t *nameW = wmc->char2wchar(titre, _nativeLangEncoding);
|
||||
preference.renameDialogTitle(TEXT("Delimiter"), nameW);
|
||||
}
|
||||
|
||||
changeDlgLang(preference._settingsOnCloudDlg.getHSelf(), "Cloud", titre);
|
||||
changeDlgLang(preference._settingsOnCloudDlg.getHSelf(), "Cloud", titre, titreMaxSize);
|
||||
if (titre[0] != '\0')
|
||||
{
|
||||
const wchar_t *nameW = wmc->char2wchar(titre, _nativeLangEncoding);
|
||||
preference.renameDialogTitle(TEXT("Cloud"), nameW);
|
||||
}
|
||||
|
||||
changeDlgLang(preference._searchEngineDlg.getHSelf(), "SearchEngine", titre);
|
||||
changeDlgLang(preference._searchEngineDlg.getHSelf(), "SearchEngine", titre, titreMaxSize);
|
||||
if (titre[0] != '\0')
|
||||
{
|
||||
const wchar_t *nameW = wmc->char2wchar(titre, _nativeLangEncoding);
|
||||
@ -1043,7 +1044,7 @@ TiXmlNodeA * NativeLangSpeaker::searchDlgNode(TiXmlNodeA *node, const char *dlgT
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool NativeLangSpeaker::changeDlgLang(HWND hDlg, const char *dlgTagName, char *title)
|
||||
bool NativeLangSpeaker::changeDlgLang(HWND hDlg, const char *dlgTagName, char *title, size_t titleMaxSize)
|
||||
{
|
||||
if (title)
|
||||
title[0] = '\0';
|
||||
@ -1059,14 +1060,14 @@ bool NativeLangSpeaker::changeDlgLang(HWND hDlg, const char *dlgTagName, char *t
|
||||
WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance();
|
||||
|
||||
// Set Title
|
||||
const char *titre = (dlgNode->ToElement())->Attribute("title");
|
||||
if ((titre && titre[0]) && hDlg)
|
||||
const char *title2set = (dlgNode->ToElement())->Attribute("title");
|
||||
if ((title2set && title2set[0]) && hDlg)
|
||||
{
|
||||
const wchar_t *nameW = wmc->char2wchar(titre, _nativeLangEncoding);
|
||||
const wchar_t *nameW = wmc->char2wchar(title2set, _nativeLangEncoding);
|
||||
::SetWindowText(hDlg, nameW);
|
||||
|
||||
if (title)
|
||||
strcpy(title, titre);
|
||||
if (title && titleMaxSize)
|
||||
strncpy(title, title2set, titleMaxSize - 1);
|
||||
}
|
||||
|
||||
// Set the text of child control
|
||||
|
@ -55,7 +55,7 @@ public:
|
||||
void changeConfigLang(HWND hDlg);
|
||||
void changeLangTabContextMenu(HMENU hCM);
|
||||
TiXmlNodeA * searchDlgNode(TiXmlNodeA *node, const char *dlgTagName);
|
||||
bool changeDlgLang(HWND hDlg, const char *dlgTagName, char *title = NULL);
|
||||
bool changeDlgLang(HWND hDlg, const char *dlgTagName, char *title = NULL, size_t titleMaxSize = 0);
|
||||
void changeLangTabDrapContextMenu(HMENU hCM);
|
||||
generic_string getSpecialMenuEntryName(const char *entryName) const;
|
||||
generic_string getNativeLangMenuString(int itemID) const;
|
||||
|
Loading…
Reference in New Issue
Block a user