Zhiyi Zhang : comdlg32: Check invalid options in IFileDialog::SetOptions.

Alexandre Julliard julliard at winehq.org
Tue Sep 18 15:14:32 CDT 2018


Module: wine
Branch: master
Commit: 616e5fa73399161055a58f1f89a6c421896f4309
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=616e5fa73399161055a58f1f89a6c421896f4309

Author: Zhiyi Zhang <zzhang at codeweavers.com>
Date:   Thu Sep 13 17:55:07 2018 +0800

comdlg32: Check invalid options in IFileDialog::SetOptions.

Fix Steam chat unable to select files.

Signed-off-by: Zhiyi Zhang <zzhang at codeweavers.com>
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/comdlg32/itemdlg.c       | 10 ++++++++++
 dlls/comdlg32/tests/itemdlg.c | 19 +++++++++++++++++++
 2 files changed, 29 insertions(+)

diff --git a/dlls/comdlg32/itemdlg.c b/dlls/comdlg32/itemdlg.c
index c8eff34..ff97ae2 100644
--- a/dlls/comdlg32/itemdlg.c
+++ b/dlls/comdlg32/itemdlg.c
@@ -2505,6 +2505,16 @@ static HRESULT WINAPI IFileDialog2_fnSetOptions(IFileDialog2 *iface, FILEOPENDIA
     FileDialogImpl *This = impl_from_IFileDialog2(iface);
     TRACE("%p (0x%x)\n", This, fos);
 
+    if (fos & ~(FOS_OVERWRITEPROMPT | FOS_STRICTFILETYPES | FOS_NOCHANGEDIR | FOS_PICKFOLDERS | FOS_FORCEFILESYSTEM
+            | FOS_ALLNONSTORAGEITEMS | FOS_NOVALIDATE | FOS_ALLOWMULTISELECT | FOS_PATHMUSTEXIST | FOS_FILEMUSTEXIST
+            | FOS_CREATEPROMPT | FOS_SHAREAWARE | FOS_NOREADONLYRETURN | FOS_NOTESTFILECREATE | FOS_HIDEMRUPLACES
+            | FOS_HIDEPINNEDPLACES | FOS_NODEREFERENCELINKS | FOS_DONTADDTORECENT | FOS_FORCESHOWHIDDEN
+            | FOS_DEFAULTNOMINIMODE | FOS_FORCEPREVIEWPANEON | FOS_SUPPORTSTREAMABLEITEMS))
+    {
+        WARN("Invalid option %#x\n", fos);
+        return E_INVALIDARG;
+    }
+
     if( !(This->options & FOS_PICKFOLDERS) && (fos & FOS_PICKFOLDERS) )
     {
         WCHAR buf[30];
diff --git a/dlls/comdlg32/tests/itemdlg.c b/dlls/comdlg32/tests/itemdlg.c
index 96c375a..03d4bb0 100644
--- a/dlls/comdlg32/tests/itemdlg.c
+++ b/dlls/comdlg32/tests/itemdlg.c
@@ -536,6 +536,8 @@ static void test_basics(void)
     const WCHAR fname2[] = {'f','n','a','m','e','2', 0};
     const WCHAR fspec2[] = {'*','.','e','x','e',0};
     COMDLG_FILTERSPEC filterspec[2] = {{fname1, fspec1}, {fname2, fspec2}};
+    const DWORD invalid_fos[] = {0x1, 0x10, 0x400, 0x80000, 0x400000, 0x800000, 0x1000000, 0x4000000, 0x8000000};
+    INT i;
 
     /* This should work on every platform with IFileDialog */
     SHGetDesktopFolder(&psfdesktop);
@@ -586,6 +588,23 @@ static void test_basics(void)
     ok(fdoptions == (FOS_OVERWRITEPROMPT | FOS_NOREADONLYRETURN | FOS_PATHMUSTEXIST | FOS_NOCHANGEDIR),
        "Unexpected default options: 0x%08x\n", fdoptions);
 
+    /* Check SetOptions invalid options handling */
+    for (i = 0; i < ARRAY_SIZE(invalid_fos); i++)
+    {
+        hr = IFileOpenDialog_SetOptions(pfod, invalid_fos[i]);
+        ok(hr == E_INVALIDARG, "got 0x%08x.\n", hr);
+        hr = IFileOpenDialog_GetOptions(pfod, &fdoptions);
+        ok(hr == S_OK, "got 0x%08x.\n", hr);
+        ok(fdoptions == (FOS_PATHMUSTEXIST | FOS_FILEMUSTEXIST | FOS_NOCHANGEDIR), "got %08x\n", fdoptions);
+
+        hr = IFileSaveDialog_SetOptions(pfsd, invalid_fos[i]);
+        ok(hr == E_INVALIDARG, "got 0x%08x.\n", hr);
+        hr = IFileSaveDialog_GetOptions(pfsd, &fdoptions);
+        ok(hr == S_OK, "got 0x%08x.\n", hr);
+        ok(fdoptions == (FOS_OVERWRITEPROMPT | FOS_NOREADONLYRETURN | FOS_PATHMUSTEXIST | FOS_NOCHANGEDIR),
+           "got %08x\n", fdoptions);
+    }
+
     /* GetResult */
     hr = IFileOpenDialog_GetResult(pfod, NULL);
     ok(hr == E_INVALIDARG, "got 0x%08x.\n", hr);




More information about the wine-cvs mailing list