mirror of
https://github.com/reactos/reactos.git
synced 2025-02-22 16:36:33 +00:00
[SHELL32] Don't hardcode C: drive again (#2777)
- Avoid buffer overrun. - Don't hardcode C: drive. CORE-13235
This commit is contained in:
parent
6c3775f77c
commit
62e59652a0
1 changed files with 21 additions and 11 deletions
|
@ -192,10 +192,12 @@ CRecycleBinEnum::~CRecycleBinEnum()
|
||||||
HRESULT WINAPI CRecycleBinEnum::Initialize(DWORD dwFlags)
|
HRESULT WINAPI CRecycleBinEnum::Initialize(DWORD dwFlags)
|
||||||
{
|
{
|
||||||
WCHAR szDrive[8];
|
WCHAR szDrive[8];
|
||||||
if (GetEnvironmentVariableW(L"SystemDrive", szDrive, _countof(szDrive)))
|
if (!GetEnvironmentVariableW(L"SystemDrive", szDrive, _countof(szDrive) - 1))
|
||||||
PathAddBackslashW(szDrive);
|
{
|
||||||
else
|
ERR("GetEnvironmentVariableW failed\n");
|
||||||
StringCbCopyW(szDrive, sizeof(szDrive), L"C:\\");
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
PathAddBackslashW(szDrive);
|
||||||
|
|
||||||
if (dwFlags & SHCONTF_NONFOLDERS)
|
if (dwFlags & SHCONTF_NONFOLDERS)
|
||||||
{
|
{
|
||||||
|
@ -367,10 +369,12 @@ HRESULT WINAPI CRecycleBinItemContextMenu::InvokeCommand(LPCMINVOKECOMMANDINFO l
|
||||||
Context.pFileDetails = _ILGetRecycleStruct(apidl);
|
Context.pFileDetails = _ILGetRecycleStruct(apidl);
|
||||||
Context.bFound = FALSE;
|
Context.bFound = FALSE;
|
||||||
|
|
||||||
if (GetEnvironmentVariableW(L"SystemDrive", szDrive, _countof(szDrive)))
|
if (!GetEnvironmentVariableW(L"SystemDrive", szDrive, _countof(szDrive) - 1))
|
||||||
PathAddBackslashW(szDrive);
|
{
|
||||||
else
|
ERR("GetEnvironmentVariableW failed\n");
|
||||||
StringCbCopyW(szDrive, sizeof(szDrive), L"C:\\");
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
PathAddBackslashW(szDrive);
|
||||||
|
|
||||||
EnumerateRecycleBinW(szDrive, CBSearchRecycleBin, (PVOID)&Context);
|
EnumerateRecycleBinW(szDrive, CBSearchRecycleBin, (PVOID)&Context);
|
||||||
if (!Context.bFound)
|
if (!Context.bFound)
|
||||||
|
@ -823,14 +827,20 @@ HRESULT WINAPI CRecycleBin::InvokeCommand(LPCMINVOKECOMMANDINFO lpcmi)
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
LPSHELLBROWSER lpSB;
|
LPSHELLBROWSER lpSB;
|
||||||
IShellView * lpSV = NULL;
|
IShellView * lpSV = NULL;
|
||||||
|
WCHAR szDrive[8];
|
||||||
|
|
||||||
TRACE("%p %p verb %p\n", this, lpcmi, lpcmi->lpVerb);
|
TRACE("%p %p verb %p\n", this, lpcmi, lpcmi->lpVerb);
|
||||||
|
|
||||||
if (LOWORD(lpcmi->lpVerb) == iIdEmpty)
|
if (LOWORD(lpcmi->lpVerb) == iIdEmpty)
|
||||||
{
|
{
|
||||||
// FIXME
|
if (!GetEnvironmentVariableW(L"SystemDrive", szDrive, _countof(szDrive) - 1))
|
||||||
// path & flags
|
{
|
||||||
hr = SHEmptyRecycleBinW(lpcmi->hwnd, L"C:\\", 0);
|
ERR("GetEnvironmentVariableW failed\n");
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
PathAddBackslashW(szDrive);
|
||||||
|
|
||||||
|
hr = SHEmptyRecycleBinW(lpcmi->hwnd, szDrive, 0);
|
||||||
TRACE("result %x\n", hr);
|
TRACE("result %x\n", hr);
|
||||||
if (hr != S_OK)
|
if (hr != S_OK)
|
||||||
return hr;
|
return hr;
|
||||||
|
|
Loading…
Reference in a new issue