https://git.reactos.org/?p=reactos.git;a=commitdiff;h=62e59652a038f8ffab2d6…
commit 62e59652a038f8ffab2d66d4af699ecc6b779a40
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Fri May 15 16:36:13 2020 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Fri May 15 16:36:13 2020 +0900
[SHELL32] Don't hardcode C: drive again (#2777)
- Avoid buffer overrun.
- Don't hardcode C: drive.
CORE-13235
---
dll/win32/shell32/folders/CRecycleBin.cpp | 32 ++++++++++++++++++++-----------
1 file changed, 21 insertions(+), 11 deletions(-)
diff --git a/dll/win32/shell32/folders/CRecycleBin.cpp
b/dll/win32/shell32/folders/CRecycleBin.cpp
index a32c42b621f..dbf03672cee 100644
--- a/dll/win32/shell32/folders/CRecycleBin.cpp
+++ b/dll/win32/shell32/folders/CRecycleBin.cpp
@@ -192,10 +192,12 @@ CRecycleBinEnum::~CRecycleBinEnum()
HRESULT WINAPI CRecycleBinEnum::Initialize(DWORD dwFlags)
{
WCHAR szDrive[8];
- if (GetEnvironmentVariableW(L"SystemDrive", szDrive, _countof(szDrive)))
- PathAddBackslashW(szDrive);
- else
- StringCbCopyW(szDrive, sizeof(szDrive), L"C:\\");
+ if (!GetEnvironmentVariableW(L"SystemDrive", szDrive, _countof(szDrive) -
1))
+ {
+ ERR("GetEnvironmentVariableW failed\n");
+ return E_FAIL;
+ }
+ PathAddBackslashW(szDrive);
if (dwFlags & SHCONTF_NONFOLDERS)
{
@@ -367,10 +369,12 @@ HRESULT WINAPI
CRecycleBinItemContextMenu::InvokeCommand(LPCMINVOKECOMMANDINFO l
Context.pFileDetails = _ILGetRecycleStruct(apidl);
Context.bFound = FALSE;
- if (GetEnvironmentVariableW(L"SystemDrive", szDrive,
_countof(szDrive)))
- PathAddBackslashW(szDrive);
- else
- StringCbCopyW(szDrive, sizeof(szDrive), L"C:\\");
+ if (!GetEnvironmentVariableW(L"SystemDrive", szDrive, _countof(szDrive)
- 1))
+ {
+ ERR("GetEnvironmentVariableW failed\n");
+ return E_FAIL;
+ }
+ PathAddBackslashW(szDrive);
EnumerateRecycleBinW(szDrive, CBSearchRecycleBin, (PVOID)&Context);
if (!Context.bFound)
@@ -823,14 +827,20 @@ HRESULT WINAPI CRecycleBin::InvokeCommand(LPCMINVOKECOMMANDINFO
lpcmi)
HRESULT hr;
LPSHELLBROWSER lpSB;
IShellView * lpSV = NULL;
+ WCHAR szDrive[8];
TRACE("%p %p verb %p\n", this, lpcmi, lpcmi->lpVerb);
if (LOWORD(lpcmi->lpVerb) == iIdEmpty)
{
- // FIXME
- // path & flags
- hr = SHEmptyRecycleBinW(lpcmi->hwnd, L"C:\\", 0);
+ if (!GetEnvironmentVariableW(L"SystemDrive", szDrive, _countof(szDrive)
- 1))
+ {
+ ERR("GetEnvironmentVariableW failed\n");
+ return E_FAIL;
+ }
+ PathAddBackslashW(szDrive);
+
+ hr = SHEmptyRecycleBinW(lpcmi->hwnd, szDrive, 0);
TRACE("result %x\n", hr);
if (hr != S_OK)
return hr;