Check if the GetWindowsDirectory call succeeded and use PathAppend to prevent a buffer overflow, when WinDir + "\regedit.exe" > MAX_PATH

svn path=/trunk/; revision=33571
This commit is contained in:
Colin Finck 2008-05-18 10:56:31 +00:00
parent b00f2fbdd7
commit 722735c754

View file

@ -1,16 +1,18 @@
#include <windows.h>
#include <tchar.h>
#include <shellapi.h>
#include <shlwapi.h>
int WINAPI _tWinMain(HINSTANCE hCurInst, HINSTANCE hPrevInst,
LPTSTR lpsCmdLine, int nCmdShow)
{
TCHAR szPath[MAX_PATH];
GetWindowsDirectory(szPath, MAX_PATH);
_tcscat(szPath, _T("\\regedit.exe"));
ShellExecute(NULL, NULL, szPath, lpsCmdLine, NULL, nCmdShow);
if(GetWindowsDirectory(szPath, MAX_PATH))
{
PathAppend(szPath, _T("regedit.exe"));
ShellExecute(NULL, NULL, szPath, lpsCmdLine, NULL, nCmdShow);
}
return 0;
}