Commit 114975d9 authored by Michael Jung's avatar Michael Jung Committed by Alexandre Julliard

Fix a lurking infinite loop in SHGetPathFromIDList.

parent 41a97576
......@@ -70,14 +70,26 @@ static const WCHAR wszDotShellClassInfo[] = {
* TRUE if returned non-NULL value.
* FALSE otherwise.
*/
BOOL SHELL32_GetCustomFolderAttribute(
LPCITEMIDLIST pidl, LPCWSTR pwszHeading, LPCWSTR pwszAttribute,
static inline BOOL SHELL32_GetCustomFolderAttributeFromPath(
LPWSTR pwszFolderPath, LPCWSTR pwszHeading, LPCWSTR pwszAttribute,
LPWSTR pwszValue, DWORD cchValue)
{
static const WCHAR wszDesktopIni[] =
{'d','e','s','k','t','o','p','.','i','n','i',0};
static const WCHAR wszDefault[] = {0};
PathAddBackslashW(pwszFolderPath);
PathAppendW(pwszFolderPath, wszDesktopIni);
return GetPrivateProfileStringW(pwszHeading, pwszAttribute, wszDefault,
pwszValue, cchValue, pwszFolderPath);
}
BOOL SHELL32_GetCustomFolderAttribute(
LPCITEMIDLIST pidl, LPCWSTR pwszHeading, LPCWSTR pwszAttribute,
LPWSTR pwszValue, DWORD cchValue)
{
DWORD dwAttrib = FILE_ATTRIBUTE_SYSTEM;
WCHAR wszFolderPath[MAX_PATH];
/* Hack around not having system attribute on non-Windows file systems */
if (0)
......@@ -85,20 +97,15 @@ BOOL SHELL32_GetCustomFolderAttribute(
if (dwAttrib & FILE_ATTRIBUTE_SYSTEM)
{
DWORD ret;
WCHAR wszDesktopIniPath[MAX_PATH];
if (!SHGetPathFromIDListW(pidl, wszDesktopIniPath))
if (!SHGetPathFromIDListW(pidl, wszFolderPath))
return FALSE;
PathAppendW(wszDesktopIniPath, wszDesktopIni);
ret = GetPrivateProfileStringW(pwszHeading, pwszAttribute,
wszDefault, pwszValue, cchValue, wszDesktopIniPath);
return ret;
return SHELL32_GetCustomFolderAttributeFromPath(wszFolderPath, pwszHeading,
pwszAttribute, pwszValue, cchValue);
}
return FALSE;
}
/***************************************************************************
* GetNextElement (internal function)
*
......@@ -277,13 +284,18 @@ HRESULT SHELL32_BindToChild (LPCITEMIDLIST pidlRoot,
/* file system folder */
CLSID clsidFolder = CLSID_ShellFSFolder;
static const WCHAR wszCLSID[] = {'C','L','S','I','D',0};
WCHAR wszCLSIDValue[CHARS_IN_GUID];
LPITEMIDLIST pidlAbsolute = ILCombine (pidlRoot, pidlChild);
WCHAR wszCLSIDValue[CHARS_IN_GUID], wszFolderPath[MAX_PATH], *pwszPathTail = wszFolderPath;
/* see if folder CLSID should be overridden by desktop.ini file */
if (SHELL32_GetCustomFolderAttribute (pidlAbsolute,
if (pathRoot) {
MultiByteToWideChar(CP_ACP, 0, pathRoot, -1, wszFolderPath, MAX_PATH);
pwszPathTail = PathAddBackslashW(wszFolderPath);
}
MultiByteToWideChar(CP_ACP, 0, _ILGetTextPointer(pidlChild), -1, pwszPathTail, MAX_PATH);
if (SHELL32_GetCustomFolderAttributeFromPath (wszFolderPath,
wszDotShellClassInfo, wszCLSID, wszCLSIDValue, CHARS_IN_GUID))
CLSIDFromString (wszCLSIDValue, &clsidFolder);
ILFree (pidlAbsolute);
hr = SHELL32_CoCreateInitSF (pidlRoot, pathRoot, pidlChild,
&clsidFolder, &IID_IShellFolder, (LPVOID *)&pSF);
}
......
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