shell32/tests: CommandLineToArgvW("") shouldn't truncate returned exe path
Ilya Basin
basinilya at gmail.com
Fri Jul 2 15:54:04 CDT 2010
This exposes http://bugs.winehq.org/show_bug.cgi?id=21758
Currently CommandLineToArgvW("") returns only the first 6 characters
of the exe path. And even worse, it doesn't terminate the result
string with 0, which can potentially cause access violations.
Here's the crosstest output:
[il at IL wine-git]$ ./wine dlls/shell32/tests/shell32_crosstest.exe shlexec
...
shlexec.c:2182: Test failed: wrong path to the current executable
expected: L"Z:\\home\\il\\builds\\wine-git\\dlls\\shell32\\tests\\shell32_crosstest.exe"
got : L"Z:\\homCe\64d0\0013("
shlexec: 411 tests executed (0 marked as todo, 21 failures), 0 skipped.
---
dlls/shell32/tests/shlexec.c | 16 +++++++++++++++-
1 files changed, 15 insertions(+), 1 deletions(-)
diff --git a/dlls/shell32/tests/shlexec.c b/dlls/shell32/tests/shlexec.c
index b883d0b..7d1cb03 100644
--- a/dlls/shell32/tests/shlexec.c
+++ b/dlls/shell32/tests/shlexec.c
@@ -2118,8 +2118,9 @@ static void test_commandline(void)
static const WCHAR chkfmt3[] = {'\\','\"','%','s','\"',0};
static const WCHAR chkfmt4[] = {'%','s','=','%','s','\"',' ','%','s','\"',0};
WCHAR cmdline[255];
- LPWSTR *args = (LPWSTR*)0xdeadcafe;
+ LPWSTR *args = (LPWSTR*)0xdeadcafe, pbuf;
INT numargs = -1;
+ size_t bufsize, buflen;
wsprintfW(cmdline,fmt1,one,two,three,four);
args=CommandLineToArgvW(cmdline,&numargs);
@@ -2170,6 +2171,19 @@ static void test_commandline(void)
wsprintfW(cmdline,fmt6);
args=CommandLineToArgvW(cmdline,&numargs);
ok(numargs == 1, "expected 1 args, got %i\n",numargs);
+ if (numargs >= 1) {
+ buflen = max(lstrlenW(args[0])+1,256);
+ bufsize = buflen*sizeof(pbuf[0]);
+ pbuf = HeapAlloc(GetProcessHeap(), 0, bufsize);
+ GetModuleFileNameW(NULL, pbuf, buflen);
+ pbuf[buflen-1] = 0;
+ /* check module file name starts with args[0] */
+ /* wine's CommandLineToArgvW may return broken string, so use wine_dbgstr_w() */
+ todo_wine ok(lstrcmpW(args[0],pbuf)==0,
+ "wrong path to the current executable\n expected: %s\n got : %s\n",
+ wine_dbgstr_w(pbuf), wine_dbgstr_w(args[0]));
+ HeapFree(GetProcessHeap(), 0, pbuf);
+ }
}
START_TEST(shlexec)
--
1.7.1
More information about the wine-patches
mailing list