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; LPTSTR p;
TCHAR szOptions[4]; 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); ConOutResPuts(STRING_COPY_HELP1);
@ -760,7 +760,7 @@ INT cmd_copy (LPTSTR first, LPTSTR rest)
DeleteFileList (sources); DeleteFileList (sources);
freep ((VOID*)p); 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); ConOutPrintf (szMsg, copied);
return 1; return 1;

View file

@ -73,7 +73,7 @@ RemoveFile (LPTSTR lpFileName, DWORD dwFlags)
LONGLONG FileSize; 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); fh = FindFirstFile(lpFileName, &f);
FileSize = ((LONGLONG)f.nFileSizeHigh * ((LONGLONG)MAXDWORD+1)) + (LONGLONG)f.nFileSizeLow; 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 */ /* Check that first element is % then an alpha char followed by space */
if ((*param != _T('%')) || !_istalpha (*(param + 1)) || !_istspace (*(param + 2))) 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); error_syntax (szMsg);
return 1; return 1;
} }

View file

@ -107,7 +107,7 @@ INT CommandTimer (LPTSTR cmd, LPTSTR param)
return 0; 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); p = split (param, &argc, FALSE);

View file

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

View file

@ -517,12 +517,12 @@ void ApplicationPageOnNotify(WPARAM wParam, LPARAM lParam)
{ {
if (pAPLI->bHung) 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); _tcsncpy(pnmdi->item.pszText, szMsg, pnmdi->item.cchTextMax);
} }
else 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); _tcsncpy(pnmdi->item.pszText, szMsg, pnmdi->item.cchTextMax);
} }
} }

View file

@ -149,7 +149,7 @@ BOOL TrayIcon_ShellAddTrayIcon(void)
nid.hIcon = hIcon; 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()); wsprintf(nid.szTip, szMsg, PerfDataGetProcessorUsage());
bRetVal = Shell_NotifyIcon(NIM_ADD, &nid); bRetVal = Shell_NotifyIcon(NIM_ADD, &nid);