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