[PATCH] [user32] Add DlgDirList wildcard checks

Vijay Kiran Kamuju infyquest at gmail.com
Fri Feb 22 07:25:59 CST 2019


Based on patch from Christian Lupien

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=8226
Signed-off-by: Vijay Kiran Kamuju <infyquest at gmail.com>
---
 dlls/user32/dialog.c        | 9 ++++++++-
 dlls/user32/tests/listbox.c | 6 +++---
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/dlls/user32/dialog.c b/dlls/user32/dialog.c
index deaeb84556..094e3ad5bf 100644
--- a/dlls/user32/dialog.c
+++ b/dlls/user32/dialog.c
@@ -1821,6 +1821,7 @@ static INT DIALOG_DlgDirListW( HWND hDlg, LPWSTR spec, INT idLBox,
     HWND hwnd;
     LPWSTR orig_spec = spec;
     WCHAR any[] = {'*','.','*',0};
+    WCHAR star[] = {'*',0};
 
 #define SENDMSG(msg,wparam,lparam) \
     ((attrib & DDL_POSTMSGS) ? PostMessageW( hwnd, msg, wparam, lparam ) \
@@ -1829,10 +1830,16 @@ static INT DIALOG_DlgDirListW( HWND hDlg, LPWSTR spec, INT idLBox,
     TRACE("%p %s %d %d %04x\n", hDlg, debugstr_w(spec), idLBox, idStatic, attrib );
 
     /* If the path exists and is a directory, chdir to it */
-    if (!spec || !spec[0] || SetCurrentDirectoryW( spec )) spec = any;
+    if (!spec || !spec[0] || SetCurrentDirectoryW( spec )) spec = star;
     else
     {
         WCHAR *p, *p2;
+        BOOL wildcards = strchrW(spec, '*') || strchrW(spec, '?');
+        if (!wildcards)
+        {
+            SetLastError(ERROR_NO_WILDCARD_CHARACTERS);
+            return FALSE;
+        }
         p = spec;
         if ((p2 = strchrW( p, ':' ))) p = p2 + 1;
         if ((p2 = strrchrW( p, '\\' ))) p = p2;
diff --git a/dlls/user32/tests/listbox.c b/dlls/user32/tests/listbox.c
index d15b18ac69..8d8115131e 100644
--- a/dlls/user32/tests/listbox.c
+++ b/dlls/user32/tests/listbox.c
@@ -1836,7 +1836,7 @@ static void test_listbox_dlgdir(void)
     strcpy(pathBuffer, "C:\\");
     res = DlgDirListA(hWnd, pathBuffer, ID_TEST_LISTBOX, 0, DDL_DIRECTORY | DDL_EXCLUSIVE);
     ok(res || broken(!res) /* NT4/W2K */, "DlgDirList failed to list C:\\ folders\n");
-    todo_wine ok(!strcmp(pathBuffer, "*") || broken(!res) /* NT4/W2K */,
+    ok(!strcmp(pathBuffer, "*") || broken(!res) /* NT4/W2K */,
        "DlgDirList set the invalid path spec '%s', expected '*'\n", pathBuffer);
 
     strcpy(pathBuffer, "C:\\*");
@@ -1849,8 +1849,8 @@ static void test_listbox_dlgdir(void)
     SetLastError(0xdeadbeef);
     strcpy(pathBuffer, "C:\\INVALID$$DIR");
     res = DlgDirListA(hWnd, pathBuffer, ID_TEST_LISTBOX, 0, DDL_DIRECTORY | DDL_EXCLUSIVE);
-    todo_wine ok(!res, "DlgDirList should have failed with 0 but %d was returned\n", res);
-    todo_wine ok(GetLastError() == ERROR_NO_WILDCARD_CHARACTERS,
+    ok(!res, "DlgDirList should have failed with 0 but %d was returned\n", res);
+    ok(GetLastError() == ERROR_NO_WILDCARD_CHARACTERS,
        "GetLastError should return 0x589, got 0x%X\n",GetLastError());
 
     DestroyWindow(hWnd);
-- 
2.20.1




More information about the wine-devel mailing list