diff --git a/dlls/shell32/shlexec.c b/dlls/shell32/shlexec.c index 2505981ddab..3196149db57 100644 --- a/dlls/shell32/shlexec.c +++ b/dlls/shell32/shlexec.c @@ -1592,14 +1592,13 @@ static BOOL SHELL_execute( LPSHELLEXECUTEINFOW sei, SHELL_ExecuteW32 execfunc ) wszApplicationName = HeapAlloc(GetProcessHeap(), 0, dwApplicationNameLen*sizeof(WCHAR)); *wszApplicationName = '\0'; } - else if (*sei_tmp.lpFile == '\"') + else if (*sei_tmp.lpFile == '\"' && sei_tmp.lpFile[(len = strlenW(sei_tmp.lpFile))-1] == '\"') { - DWORD l = strlenW(sei_tmp.lpFile+1); - if(l >= dwApplicationNameLen) dwApplicationNameLen = l+1; + if(len-1 >= dwApplicationNameLen) dwApplicationNameLen = len; wszApplicationName = HeapAlloc(GetProcessHeap(), 0, dwApplicationNameLen*sizeof(WCHAR)); - memcpy(wszApplicationName, sei_tmp.lpFile+1, (l+1)*sizeof(WCHAR)); - if (wszApplicationName[l-1] == '\"') - wszApplicationName[l-1] = '\0'; + memcpy(wszApplicationName, sei_tmp.lpFile+1, len*sizeof(WCHAR)); + if(len > 2) + wszApplicationName[len-2] = '\0'; TRACE("wszApplicationName=%s\n",debugstr_w(wszApplicationName)); } else { DWORD l = strlenW(sei_tmp.lpFile)+1; diff --git a/dlls/shell32/tests/shlexec.c b/dlls/shell32/tests/shlexec.c index e3b245a6594..3d95b4148e5 100644 --- a/dlls/shell32/tests/shlexec.c +++ b/dlls/shell32/tests/shlexec.c @@ -905,6 +905,8 @@ static filename_tests_t filename_tests[]= {NULL, "%s\\masked file.shlexec", 0x0, 33}, /* Test if quoting prevents the masking */ {NULL, "%s\\masked file.shlexec", 0x40, 33}, + /* Test with incorrect quote */ + {NULL, "\"%s\\masked file.shlexec", 0x0, SE_ERR_FNF}, {NULL, NULL, 0} }; @@ -2114,6 +2116,15 @@ static void test_exes(void) { win_skip("Skipping shellexecute of file with unassociated extension\n"); } + + /* test combining executable and parameters */ + sprintf(filename, "%s shlexec \"%s\" Exec", argv0, child_file); + rc = shell_execute(NULL, filename, NULL, NULL); + ok(rc == SE_ERR_FNF, "%s returned %lu\n", shell_call, rc); + + sprintf(filename, "\"%s\" shlexec \"%s\" Exec", argv0, child_file); + rc = shell_execute(NULL, filename, NULL, NULL); + ok(rc == SE_ERR_FNF, "%s returned %lu\n", shell_call, rc); } typedef struct