https://git.reactos.org/?p=reactos.git;a=commitdiff;h=332889b8d7b452df9bd899...
commit 332889b8d7b452df9bd899a5ed04d41dd22876de Author: Mark Jansen mark.jansen@reactos.org AuthorDate: Wed May 6 22:04:11 2020 +0200 Commit: Mark Jansen mark.jansen@reactos.org CommitDate: Sun May 17 17:09:05 2020 +0200
[COMDLG32] Differentiate between real and virtual folders, do not allow traversal inside virtual folders when selecting a file CORE-16908 --- dll/win32/comdlg32/filedlg.c | 8 ++++---- dll/win32/comdlg32/filedlgbrowser.c | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/dll/win32/comdlg32/filedlg.c b/dll/win32/comdlg32/filedlg.c index af3c5c4a3ac..6e5134f6ce3 100644 --- a/dll/win32/comdlg32/filedlg.c +++ b/dll/win32/comdlg32/filedlg.c @@ -2782,12 +2782,12 @@ int FILEDLG95_ValidatePathAction(LPWSTR lpstrPathAndFile, IShellFolder **ppsf, PathAddBackslashW(lpwstrTemp); }
- dwAttributes = SFGAO_FOLDER; + dwAttributes = SFGAO_FOLDER | SFGAO_FILESYSANCESTOR; if(SUCCEEDED(IShellFolder_ParseDisplayName(*ppsf, hwnd, NULL, lpwstrTemp, &dwEaten, &pidl, &dwAttributes))) { /* the path component is valid, we have a pidl of the next path component */ TRACE("parse OK attr=0x%08x pidl=%p\n", dwAttributes, pidl); - if(dwAttributes & SFGAO_FOLDER) + if((dwAttributes & (SFGAO_FOLDER | SFGAO_FILESYSANCESTOR)) == (SFGAO_FOLDER | SFGAO_FILESYSANCESTOR)) { if(FAILED(IShellFolder_BindToObject(*ppsf, pidl, 0, &IID_IShellFolder, (LPVOID*)&lpsfChild))) { @@ -4468,7 +4468,7 @@ static LPITEMIDLIST GetPidlFromName(IShellFolder *lpsf,LPWSTR lpcstrFileName) */ static BOOL IsPidlFolder (LPSHELLFOLDER psf, LPCITEMIDLIST pidl) { - ULONG uAttr = SFGAO_FOLDER | SFGAO_HASSUBFOLDER; + ULONG uAttr = SFGAO_FOLDER | SFGAO_HASSUBFOLDER | SFGAO_FILESYSANCESTOR; HRESULT ret;
TRACE("%p, %p\n", psf, pidl); @@ -4477,7 +4477,7 @@ static BOOL IsPidlFolder (LPSHELLFOLDER psf, LPCITEMIDLIST pidl)
TRACE("-- 0x%08x 0x%08x\n", uAttr, ret); /* see documentation shell 4.1*/ - return uAttr & (SFGAO_FOLDER | SFGAO_HASSUBFOLDER); + return (uAttr & (SFGAO_FOLDER | SFGAO_HASSUBFOLDER)) && (uAttr & SFGAO_FILESYSANCESTOR); }
/*********************************************************************** diff --git a/dll/win32/comdlg32/filedlgbrowser.c b/dll/win32/comdlg32/filedlgbrowser.c index 5b5323f4d22..83d5f5e9e09 100644 --- a/dll/win32/comdlg32/filedlgbrowser.c +++ b/dll/win32/comdlg32/filedlgbrowser.c @@ -774,9 +774,9 @@ static HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand(ICommDl { HRESULT hRes;
- ULONG ulAttr = SFGAO_FOLDER | SFGAO_HASSUBFOLDER; + ULONG ulAttr = SFGAO_FOLDER | SFGAO_HASSUBFOLDER | SFGAO_FILESYSANCESTOR; IShellFolder_GetAttributesOf(fodInfos->Shell.FOIShellFolder, 1, (LPCITEMIDLIST *)&pidl, &ulAttr); - if (ulAttr & (SFGAO_FOLDER | SFGAO_HASSUBFOLDER) ) + if ((ulAttr & (SFGAO_FOLDER | SFGAO_HASSUBFOLDER)) && (ulAttr & SFGAO_FILESYSANCESTOR)) { hRes = IShellBrowser_BrowseObject(&This->IShellBrowser_iface,pidl,SBSP_RELATIVE); if(fodInfos->ofnInfos->Flags & OFN_EXPLORER)