https://git.reactos.org/?p=reactos.git;a=commitdiff;h=abf3bde91b1f76f571423…
commit abf3bde91b1f76f571423ea2c0bf6decea8abb15
Author: Whindmar Saksit <whindsaks(a)proton.me>
AuthorDate: Fri Oct 11 23:47:06 2024 +0200
Commit: GitHub <noreply(a)github.com>
CommitDate: Fri Oct 11 23:47:06 2024 +0200
[SHELL32] Make Recycle Bin PIDL data handling more robust (#7328)
---
dll/win32/shell32/folders/CRecycleBin.cpp | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/dll/win32/shell32/folders/CRecycleBin.cpp
b/dll/win32/shell32/folders/CRecycleBin.cpp
index 7bcfe96391e..32f51b3ba8a 100644
--- a/dll/win32/shell32/folders/CRecycleBin.cpp
+++ b/dll/win32/shell32/folders/CRecycleBin.cpp
@@ -750,15 +750,20 @@ HRESULT WINAPI CRecycleBin::GetDetailsOf(PCUITEMID_CHILD pidl, UINT
iColumn, LPS
TRACE("(%p, %p, %d, %p)\n", this, pidl, iColumn, pDetails);
if (iColumn >= COLUMNS_COUNT)
return E_FAIL;
- pDetails->fmt = RecycleBinColumns[iColumn].fmt;
- pDetails->cxChar = RecycleBinColumns[iColumn].cxChars;
+
if (pidl == NULL)
+ {
+ pDetails->fmt = RecycleBinColumns[iColumn].fmt;
+ pDetails->cxChar = RecycleBinColumns[iColumn].cxChars;
return SHSetStrRet(&pDetails->str,
RecycleBinColumns[iColumn].column_name_id);
+ }
if (iColumn == COLUMN_NAME)
return GetDisplayNameOf(pidl, SHGDN_NORMAL, &pDetails->str);
pFileDetails = _ILGetRecycleStruct(pidl);
+ if (!pFileDetails && FAILED_UNEXPECTEDLY(E_INVALIDARG))
+ return E_INVALIDARG;
switch (iColumn)
{
case COLUMN_DATEDEL:
@@ -766,8 +771,16 @@ HRESULT WINAPI CRecycleBin::GetDetailsOf(PCUITEMID_CHILD pidl, UINT
iColumn, LPS
break;
case COLUMN_DELFROM:
pszBackslash = wcsrchr(pFileDetails->szName, L'\\');
- Length = (pszBackslash - pFileDetails->szName);
- memcpy((LPVOID)buffer, pFileDetails->szName, Length * sizeof(WCHAR));
+ if (!pszBackslash)
+ {
+ ERR("Filename '%ls' not a valid path?\n",
pFileDetails->szName);
+ Length = 0;
+ }
+ else
+ {
+ Length = (pszBackslash - pFileDetails->szName);
+ memcpy((LPVOID)buffer, pFileDetails->szName, Length * sizeof(WCHAR));
+ }
buffer[Length] = UNICODE_NULL;
if (buffer[0] && buffer[1] == L':' && !buffer[2])
{