[EU-FOSSA] Fix buffer overrun in Print dialog
This commit is contained in:
parent
194475ce64
commit
0adc06322f
@ -2387,22 +2387,33 @@ INT_PTR CALLBACK PrintSettingsDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
|
|||||||
|
|
||||||
case IDC_BUTTON_ADDVAR:
|
case IDC_BUTTON_ADDVAR:
|
||||||
{
|
{
|
||||||
if (!_focusedEditCtrl)
|
try {
|
||||||
return TRUE;
|
if (!_focusedEditCtrl)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
auto iSel = ::SendDlgItemMessage(_hSelf, IDC_COMBO_VARLIST, CB_GETCURSEL, 0, 0);
|
auto iSel = ::SendDlgItemMessage(_hSelf, IDC_COMBO_VARLIST, CB_GETCURSEL, 0, 0);
|
||||||
TCHAR *varStr = (TCHAR *)::SendDlgItemMessage(_hSelf, IDC_COMBO_VARLIST, CB_GETITEMDATA, iSel, 0);
|
TCHAR *varStr = (TCHAR *)::SendDlgItemMessage(_hSelf, IDC_COMBO_VARLIST, CB_GETITEMDATA, iSel, 0);
|
||||||
|
DWORD selStart = 0;
|
||||||
|
DWORD selEnd = 0;
|
||||||
|
::SendDlgItemMessage(_hSelf, _focusedEditCtrl, EM_GETSEL, reinterpret_cast<WPARAM>(&selStart), reinterpret_cast<LPARAM>(&selEnd));
|
||||||
|
|
||||||
::SendDlgItemMessage(_hSelf, _focusedEditCtrl, EM_GETSEL, reinterpret_cast<WPARAM>(&_selStart), reinterpret_cast<LPARAM>(&_selEnd));
|
const int stringSize = 256;
|
||||||
|
TCHAR str[stringSize];
|
||||||
|
::SendDlgItemMessage(_hSelf, _focusedEditCtrl, WM_GETTEXT, stringSize, reinterpret_cast<LPARAM>(str));
|
||||||
|
|
||||||
const int stringSize = 256;
|
generic_string str2Set(str);
|
||||||
TCHAR str[stringSize];
|
size_t strLen = str2Set.length();
|
||||||
::SendDlgItemMessage(_hSelf, _focusedEditCtrl, WM_GETTEXT, stringSize, reinterpret_cast<LPARAM>(str));
|
if (selStart > strLen || selEnd > strLen)
|
||||||
|
selStart = selEnd = strLen;
|
||||||
|
|
||||||
generic_string str2Set(str);
|
str2Set.replace(selStart, selEnd - selStart, varStr);
|
||||||
str2Set.replace(_selStart, _selEnd - _selStart, varStr);
|
|
||||||
|
::SetDlgItemText(_hSelf, _focusedEditCtrl, str2Set.c_str());
|
||||||
::SetDlgItemText(_hSelf, _focusedEditCtrl, str2Set.c_str());
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -148,13 +148,11 @@ struct strCouple {
|
|||||||
class PrintSettingsDlg : public StaticDialog
|
class PrintSettingsDlg : public StaticDialog
|
||||||
{
|
{
|
||||||
public :
|
public :
|
||||||
PrintSettingsDlg():_focusedEditCtrl(0), _selStart(0), _selEnd(0){};
|
PrintSettingsDlg(){};
|
||||||
private :
|
private :
|
||||||
INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
|
INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
|
||||||
std::vector<strCouple> varList;
|
std::vector<strCouple> varList;
|
||||||
int _focusedEditCtrl;
|
int _focusedEditCtrl = 0;
|
||||||
DWORD _selStart;
|
|
||||||
DWORD _selEnd;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class BackupDlg : public StaticDialog
|
class BackupDlg : public StaticDialog
|
||||||
|
Loading…
Reference in New Issue
Block a user