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