- more checks for valid pidl formats

This commit is contained in:
Juergen Schmied 1999-04-22 09:20:01 +00:00 committed by Alexandre Julliard
parent 55c0bcaf5c
commit 3ea18db36d
6 changed files with 63 additions and 6 deletions

View File

@ -195,7 +195,7 @@ static HRESULT WINAPI IExtractIconA_fnGetIconLocation(
}
}
TRACE (shell,"-- %s %x\n", debugstr_a(szIconFile), *piIndex);
TRACE (shell,"-- %s %x\n", (ret==NOERROR)?debugstr_a(szIconFile):"[error]", *piIndex);
return ret;
}
/**************************************************************************

View File

@ -694,11 +694,13 @@ BOOL PidlToSicIndex (IShellFolder * sh, LPITEMIDLIST pidl, BOOL bBigIcon, UINT *
BOOL ret = FALSE;
UINT dwFlags = 0;
TRACE(shell,"sf=%p pidl=%p\n", sh, pidl);
if (SUCCEEDED (IShellFolder_GetUIObjectOf(sh, 0, 1, &pidl, &IID_IExtractIconA, 0, (void **)&ei)))
{
if (SUCCEEDED (IExtractIconA_GetIconLocation(ei, 0, szIconFile, MAX_PATH, &iSourceIndex, &dwFlags)))
{ *pIndex = SIC_GetIconIndex(szIconFile, iSourceIndex);
ret = TRUE;
if (NOERROR==IExtractIconA_GetIconLocation(ei, 0, szIconFile, MAX_PATH, &iSourceIndex, &dwFlags))
{ *pIndex = SIC_GetIconIndex(szIconFile, iSourceIndex);
ret = TRUE;
}
IExtractIconA_Release(ei);
}

View File

@ -54,6 +54,45 @@ void pdump (LPCITEMIDLIST pidl)
TRACE(pidl,"empty pidl (Desktop)\n");
}
BOOL pcheck (LPCITEMIDLIST pidl)
{ DWORD type, ret=TRUE;
LPITEMIDLIST pidltemp = pidl;
if (pidltemp && pidltemp->mkid.cb)
{ do
{ type = _ILGetDataPointer(pidltemp)->type;
switch (type)
{ case PT_DESKTOP:
case PT_MYCOMP:
case PT_SPECIAL:
case PT_DRIVE:
case PT_FOLDER:
case PT_VALUE:
break;
default:
{
char szTemp[100]; /* 3*32 + 3 + 1 */
int i;
for ( i = 0; i < pidltemp->mkid.cb; i++)
{
sprintf (&(szTemp[i*3]),"%02x ", ((LPBYTE)pidltemp)[i]);
if (i>=31)
{
sprintf (&(szTemp[i*3+3]),"...");
break;
}
}
ERR (pidl,"unknown IDLIST type size=%u type=%lx\n%s\n",pidltemp->mkid.cb,type, szTemp);
ret = FALSE;
}
}
pidltemp = ILGetNext(pidltemp);
} while (pidltemp->mkid.cb);
}
return ret;
}
/*************************************************************************
* ILGetDisplayName [SHELL32.15]
*/
@ -169,6 +208,13 @@ HRESULT WINAPI ILLoadFromStream (IStream * pStream, LPITEMIDLIST * ppPidl)
*ppPidl = NULL;
}
}
/* we are not jet fully compatible */
if (!pcheck(*ppPidl))
{ SHFree(*ppPidl);
*ppPidl = NULL;
}
IStream_Release (pStream);
@ -274,6 +320,11 @@ BOOL WINAPI ILIsEqual(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
TRACE(pidl,"pidl1=%p pidl2=%p\n",pidl1, pidl2);
/* explorer reads from registry directly (StreamMRU),
so we can only check here */
if ((!pcheck (pidl1)) || (!pcheck (pidl2)))
return FALSE;
pdump (pidl1);
pdump (pidl2);

View File

@ -121,4 +121,5 @@ LPSTR WINAPI _ILGetTextPointer(PIDLTYPE type, LPPIDLDATA pidldata);
LPSTR WINAPI _ILGetSTextPointer(PIDLTYPE type, LPPIDLDATA pidldata);
void pdump (LPCITEMIDLIST pidl);
BOOL pcheck (LPCITEMIDLIST pidl);
#endif

View File

@ -74,7 +74,7 @@ HRESULT WINAPI StrRetToStrN (LPVOID dest, DWORD len, LPSTRRET src, LPITEMIDLIST
#define INVALID_INDEX -1
BOOL SIC_Initialize(void);
void SIC_Destroy(void);
/*INT32 SIC_GetIconIndex (LPCSTR sSourceFile, INT32 dwSourceIndex );*/
BOOL PidlToSicIndex (IShellFolder * sh, LPITEMIDLIST pidl, BOOL bBigIcon, UINT * pIndex);
/* Classes Root */
BOOL HCR_MapTypeToValue ( LPCSTR szExtension, LPSTR szFileType, DWORD len);

View File

@ -209,11 +209,14 @@ static HRESULT WINAPI IPersistFile_fnLoad(IPersistFile* iface, LPCOLESTR pszFile
pdump (&pImage->Pidl);
}
if (!pcheck (&pImage->Pidl))
goto end_3;
This->pPidl = ILClone (&pImage->Pidl);
_ILGetPidlPath(&pImage->Pidl, sTemp, 512);
This->sPath = HEAP_strdupA ( GetProcessHeap(), 0, sTemp);
hRet = NOERROR;
end_3: UnmapViewOfFile(pImage);
end_2: CloseHandle(hMapping);