size the buffer dynamically to avoid potentially overflowing it

svn path=/trunk/; revision=23438
This commit is contained in:
Ged Murphy 2006-08-03 19:06:12 +00:00
parent c6b0db6688
commit 728a261829

View file

@ -466,14 +466,25 @@ DisplayTCPIPProperties(HWND hParent, IP_ADAPTER_INFO *pInfo)
PROPSHEETHEADERW psh; PROPSHEETHEADERW psh;
INITCOMMONCONTROLSEX cce; INITCOMMONCONTROLSEX cce;
TCPIP_PROPERTIES_DATA DlgData; TCPIP_PROPERTIES_DATA DlgData;
TCHAR tpszCaption[MAX_PATH]; LPTSTR tpszCaption = NULL;
INT StrLen;
HWND hListBox = GetDlgItem(hParent, IDC_COMPONENTSLIST); HWND hListBox = GetDlgItem(hParent, IDC_COMPONENTSLIST);
int iListBoxIndex = (int) SendMessage(hListBox, LB_GETCURSEL, 0, 0); int iListBoxIndex = (int) SendMessage(hListBox, LB_GETCURSEL, 0, 0);
if(iListBoxIndex != LB_ERR) if(iListBoxIndex != LB_ERR)
{
StrLen = SendMessage(hListBox, LB_GETTEXTLEN, iListBoxIndex, 0);
if (StrLen != LB_ERR)
{
TCHAR suffix[] = _T(" Properties");
INT HeapSize = ((StrLen + 1) + (_tcslen(suffix) + 1)) * sizeof(TCHAR);
tpszCaption = (LPTSTR)HeapAlloc(GetProcessHeap(), 0, HeapSize);
SendMessage(hListBox, LB_GETTEXT, iListBoxIndex, (LPARAM)tpszCaption); SendMessage(hListBox, LB_GETTEXT, iListBoxIndex, (LPARAM)tpszCaption);
else _tcscat(tpszCaption, suffix);
_stprintf(tpszCaption,_T("[ERROR]")); }
_tcscat(tpszCaption,_T(" Properties")); }
if (! LoadDataFromInfo(&DlgData, pInfo)) if (! LoadDataFromInfo(&DlgData, pInfo))
{ {