[SHELL32] Make Recycle Bin PIDL data handling more robust (#7328)

This commit is contained in:
Whindmar Saksit 2024-10-11 23:47:06 +02:00 committed by GitHub
parent 08a6834075
commit abf3bde91b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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])
{