Commit 3ea18db3 authored by Juergen Schmied's avatar Juergen Schmied Committed by Alexandre Julliard

- more checks for valid pidl formats

parent 55c0bcaf
......@@ -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;
}
/**************************************************************************
......
......@@ -694,9 +694,11 @@ 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)))
if (NOERROR==IExtractIconA_GetIconLocation(ei, 0, szIconFile, MAX_PATH, &iSourceIndex, &dwFlags))
{ *pIndex = SIC_GetIconIndex(szIconFile, iSourceIndex);
ret = TRUE;
}
......
......@@ -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]
*/
......@@ -170,6 +209,13 @@ HRESULT WINAPI ILLoadFromStream (IStream * pStream, LPITEMIDLIST * ppPidl)
}
}
/* we are not jet fully compatible */
if (!pcheck(*ppPidl))
{ SHFree(*ppPidl);
*ppPidl = NULL;
}
IStream_Release (pStream);
return ret;
......@@ -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);
......
......@@ -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
......@@ -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);
......
......@@ -209,6 +209,9 @@ 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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment