prevent buffer overflow, LoadString accepts the size of the buffer in TCHARs, not in bytes! Please guys, read the documentation of the function _before_ you use it...

svn path=/trunk/; revision=15149
This commit is contained in:
Thomas Bluemel 2005-05-08 19:22:28 +00:00
parent 539af1d0d0
commit 54f6a09bb2
7 changed files with 16 additions and 16 deletions

View file

@ -299,7 +299,7 @@ Overwrite (LPTSTR fn)
LPTSTR p;
TCHAR szOptions[4];
LoadString( CMD_ModuleHandle, STRING_COPY_OPTION, szOptions, 4);
LoadString( CMD_ModuleHandle, STRING_COPY_OPTION, szOptions, sizeof(szOptions) / sizeof(szOptions[0]) );
ConOutResPuts(STRING_COPY_HELP1);
@ -760,7 +760,7 @@ INT cmd_copy (LPTSTR first, LPTSTR rest)
DeleteFileList (sources);
freep ((VOID*)p);
LoadString( CMD_ModuleHandle, STRING_COPY_FILE, (LPTSTR) szMsg,sizeof(szMsg));
LoadString( CMD_ModuleHandle, STRING_COPY_FILE, szMsg, RC_STRING_MAX_SIZE);
ConOutPrintf (szMsg, copied);
return 1;

View file

@ -71,9 +71,9 @@ RemoveFile (LPTSTR lpFileName, DWORD dwFlags)
HANDLE fh;
WIN32_FIND_DATA f;
LONGLONG FileSize;
TCHAR szMsg[RC_STRING_MAX_SIZE];
TCHAR szMsg[RC_STRING_MAX_SIZE];
LoadString( CMD_ModuleHandle, STRING_DELETE_WIPE, (LPTSTR) szMsg,sizeof(szMsg));
LoadString( CMD_ModuleHandle, STRING_DELETE_WIPE, szMsg, RC_STRING_MAX_SIZE);
fh = FindFirstFile(lpFileName, &f);
FileSize = ((LONGLONG)f.nFileSizeHigh * ((LONGLONG)MAXDWORD+1)) + (LONGLONG)f.nFileSizeLow;

View file

@ -68,7 +68,7 @@ INT cmd_for (LPTSTR cmd, LPTSTR param)
/* Check that first element is % then an alpha char followed by space */
if ((*param != _T('%')) || !_istalpha (*(param + 1)) || !_istspace (*(param + 2)))
{
LoadString( CMD_ModuleHandle, STRING_FOR_ERROR, (LPTSTR) szMsg,sizeof(szMsg));
LoadString( CMD_ModuleHandle, STRING_FOR_ERROR, szMsg, RC_STRING_MAX_SIZE);
error_syntax (szMsg);
return 1;
}

View file

@ -107,7 +107,7 @@ INT CommandTimer (LPTSTR cmd, LPTSTR param)
return 0;
}
LoadString( CMD_ModuleHandle, STRING_TIMER_TIME, (LPTSTR) szMsg,sizeof(szMsg));
LoadString( CMD_ModuleHandle, STRING_TIMER_TIME, szMsg, RC_STRING_MAX_SIZE);
p = split (param, &argc, FALSE);

View file

@ -46,8 +46,8 @@ VOID ShortVersion (VOID)
(RosVersion - VersionInfo.szCSDVersion);
if (7 <= RosVersionLen && 0 == _tcsnicmp(RosVersion, _T("ReactOS"), 7))
{
LoadString( CMD_ModuleHandle, STRING_VERSION_RUNVER, (LPTSTR) szMsg,sizeof(szMsg));
ConOutPrintf (szMsg, RosVersion);
LoadString( CMD_ModuleHandle, STRING_VERSION_RUNVER, (LPTSTR) szMsg, RC_STRING_MAX_SIZE);
ConOutPrintf (szMsg, RosVersion);
}
}
ConOutPuts (_T("\n"));

View file

@ -489,7 +489,7 @@ void ApplicationPageOnNotify(WPARAM wParam, LPARAM lParam)
LPNM_LISTVIEW pnmv;
LV_DISPINFO* pnmdi;
LPAPPLICATION_PAGE_LIST_ITEM pAPLI;
TCHAR szMsg[256];
TCHAR szMsg[256];
idctrl = (int) wParam;
@ -516,15 +516,15 @@ void ApplicationPageOnNotify(WPARAM wParam, LPARAM lParam)
else if (pnmdi->item.iSubItem == 1)
{
if (pAPLI->bHung)
{
LoadString( GetModuleHandle(NULL), IDS_Not_Responding , (LPTSTR) szMsg,sizeof(szMsg));
{
LoadString( GetModuleHandle(NULL), IDS_Not_Responding , szMsg, sizeof(szMsg) / sizeof(szMsg[0]));
_tcsncpy(pnmdi->item.pszText, szMsg, pnmdi->item.cchTextMax);
}
}
else
{
LoadString( GetModuleHandle(NULL), IDS_Running, (LPTSTR) szMsg,sizeof(szMsg));
{
LoadString( GetModuleHandle(NULL), IDS_Running, (LPTSTR) szMsg, sizeof(szMsg) / sizeof(szMsg[0]));
_tcsncpy(pnmdi->item.pszText, szMsg, pnmdi->item.cchTextMax);
}
}
}
break;

View file

@ -149,7 +149,7 @@ BOOL TrayIcon_ShellAddTrayIcon(void)
nid.hIcon = hIcon;
LoadString( GetModuleHandle(NULL), IDS_MSG_TRAYICONCPUUSAGE, (LPTSTR) szMsg,sizeof(szMsg));
LoadString( GetModuleHandle(NULL), IDS_MSG_TRAYICONCPUUSAGE, szMsg, sizeof(szMsg) / sizeof(szMsg[0]));
wsprintf(nid.szTip, szMsg, PerfDataGetProcessorUsage());
bRetVal = Shell_NotifyIcon(NIM_ADD, &nid);