Commit 9d78f678 authored by Martin Fuchs's avatar Martin Fuchs Committed by Alexandre Julliard

Only return valid file system names from RenderFILENAMEA/W() by using

SHELL_GetPathFromIDListA/W().
parent aa43d016
...@@ -209,17 +209,24 @@ HGLOBAL RenderFILEDESCRIPTOR (LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT ...@@ -209,17 +209,24 @@ HGLOBAL RenderFILEDESCRIPTOR (LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT
HGLOBAL RenderFILENAMEA (LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl) HGLOBAL RenderFILENAMEA (LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl)
{ {
int len, size = 0; int size = 0;
char szTemp[MAX_PATH], *szFileName; char szTemp[MAX_PATH], *szFileName;
LPITEMIDLIST pidl;
HGLOBAL hGlobal; HGLOBAL hGlobal;
HRESULT hr;
TRACE("(%p,%p,%u)\n", pidlRoot, apidl, cidl); TRACE("(%p,%p,%u)\n", pidlRoot, apidl, cidl);
/* build name of first file */ /* get path of combined pidl */
SHGetPathFromIDListA(pidlRoot, szTemp); pidl = ILCombine(pidlRoot, apidl[0]);
PathAddBackslashA(szTemp); if (!pidl)
len = strlen(szTemp); return 0;
_ILSimpleGetText(apidl[0], szTemp+len, MAX_PATH - len);
hr = SHELL_GetPathFromIDListA(pidl, szTemp, MAX_PATH);
SHFree(pidl);
if (FAILED(hr))
return 0;
size = strlen(szTemp) + 1; size = strlen(szTemp) + 1;
/* fill the structure */ /* fill the structure */
...@@ -228,23 +235,31 @@ HGLOBAL RenderFILENAMEA (LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl) ...@@ -228,23 +235,31 @@ HGLOBAL RenderFILENAMEA (LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl)
szFileName = (char *)GlobalLock(hGlobal); szFileName = (char *)GlobalLock(hGlobal);
memcpy(szFileName, szTemp, size); memcpy(szFileName, szTemp, size);
GlobalUnlock(hGlobal); GlobalUnlock(hGlobal);
return hGlobal; return hGlobal;
} }
HGLOBAL RenderFILENAMEW (LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl) HGLOBAL RenderFILENAMEW (LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl)
{ {
int len, size = 0; int size = 0;
WCHAR szTemp[MAX_PATH], *szFileName; WCHAR szTemp[MAX_PATH], *szFileName;
LPITEMIDLIST pidl;
HGLOBAL hGlobal; HGLOBAL hGlobal;
HRESULT hr;
TRACE("(%p,%p,%u)\n", pidlRoot, apidl, cidl); TRACE("(%p,%p,%u)\n", pidlRoot, apidl, cidl);
/* build name of first file */ /* get path of combined pidl */
SHGetPathFromIDListW(pidlRoot, szTemp); pidl = ILCombine(pidlRoot, apidl[0]);
PathAddBackslashW(szTemp); if (!pidl)
len = strlenW(szTemp); return 0;
_ILSimpleGetTextW(apidl[0], szTemp+len, MAX_PATH - len);
size = sizeof(WCHAR) * (strlenW(szTemp)+1); hr = SHELL_GetPathFromIDListW(pidl, szTemp, MAX_PATH);
SHFree(pidl);
if (FAILED(hr))
return 0;
size = (strlenW(szTemp)+1) * sizeof(WCHAR);
/* fill the structure */ /* fill the structure */
hGlobal = GlobalAlloc(GHND|GMEM_SHARE, size); hGlobal = GlobalAlloc(GHND|GMEM_SHARE, size);
...@@ -252,6 +267,7 @@ HGLOBAL RenderFILENAMEW (LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl) ...@@ -252,6 +267,7 @@ HGLOBAL RenderFILENAMEW (LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl)
szFileName = (WCHAR *)GlobalLock(hGlobal); szFileName = (WCHAR *)GlobalLock(hGlobal);
memcpy(szFileName, szTemp, size); memcpy(szFileName, szTemp, size);
GlobalUnlock(hGlobal); GlobalUnlock(hGlobal);
return hGlobal; return hGlobal;
} }
......
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