Author: gedmurphy
Date: Thu Aug 3 23:06:12 2006
New Revision: 23438
URL:
http://svn.reactos.org/svn/reactos?rev=23438&view=rev
Log:
size the buffer dynamically to avoid potentially overflowing it
Modified:
trunk/reactos/dll/cpl/ncpa/tcpip_properties.c
Modified: trunk/reactos/dll/cpl/ncpa/tcpip_properties.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/ncpa/tcpip_propert…
==============================================================================
--- trunk/reactos/dll/cpl/ncpa/tcpip_properties.c (original)
+++ trunk/reactos/dll/cpl/ncpa/tcpip_properties.c Thu Aug 3 23:06:12 2006
@@ -466,14 +466,25 @@
PROPSHEETHEADERW psh;
INITCOMMONCONTROLSEX cce;
TCPIP_PROPERTIES_DATA DlgData;
- TCHAR tpszCaption[MAX_PATH];
- HWND hListBox = GetDlgItem(hParent,IDC_COMPONENTSLIST);
- int iListBoxIndex = (int) SendMessage(hListBox,LB_GETCURSEL,0,0);
+ LPTSTR tpszCaption = NULL;
+ INT StrLen;
+
+ HWND hListBox = GetDlgItem(hParent, IDC_COMPONENTSLIST);
+ int iListBoxIndex = (int) SendMessage(hListBox, LB_GETCURSEL, 0, 0);
+
if(iListBoxIndex != LB_ERR)
- SendMessage(hListBox,LB_GETTEXT,iListBoxIndex,(LPARAM)tpszCaption);
- else
- _stprintf(tpszCaption,_T("[ERROR]"));
- _tcscat(tpszCaption,_T(" Properties"));
+ {
+ 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);
+ _tcscat(tpszCaption, suffix);
+ }
+ }
if (! LoadDataFromInfo(&DlgData, pInfo))
{