[PATCH 2/3] comdlg32: Check invalid options in IFileDialog::SetOptions.

Nikolay Sivov nsivov at codeweavers.com
Fri Sep 7 11:08:42 CDT 2018


On 09/07/2018 04:19 PM, Zhiyi Zhang wrote:

> Fix Steam chat unable to select files.
>
> Signed-off-by: Zhiyi Zhang <zzhang at codeweavers.com>
> ---
>   dlls/comdlg32/itemdlg.c       |  8 ++++++++
>   dlls/comdlg32/tests/itemdlg.c | 19 +++++++++++++++++++
>   2 files changed, 27 insertions(+)
>
> diff --git a/dlls/comdlg32/itemdlg.c b/dlls/comdlg32/itemdlg.c
> index c8eff3438d..c3454c92cd 100644
> --- a/dlls/comdlg32/itemdlg.c
> +++ b/dlls/comdlg32/itemdlg.c
> @@ -2505,6 +2505,14 @@ static HRESULT WINAPI IFileDialog2_fnSetOptions(IFileDialog2 *iface, FILEOPENDIA
>       FileDialogImpl *This = impl_from_IFileDialog2(iface);
>       TRACE("%p (0x%x)\n", This, fos);
>   
> +    /* 0xDC80411 = Invalid FILEOPENDIALOGOPTIONS enums OR result =
> +     * 0x1 | 0x10 | 0x400 | 0x80000 | 0x400000 | 0x800000 | 0x1000000 | 0x4000000 | 0x8000000 */
> +    if(fos & 0xDC80411)
> +    {
> +        FIXME("FILEOPENDIALOGOPTIONS 0x%08x contains unknown enums\n", fos);
> +        return E_INVALIDARG;
> +    }
> +

Could you turn this to a bitmask of known values instead? Also with a 
WARN, since we have tests for that case.

>       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 d3be8c8d29..6b63063e29 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-devel mailing list