Module: wine Branch: master Commit: 943ead502295793f608ad65eb0ca144ba67546ce URL: http://source.winehq.org/git/wine.git/?a=commit;h=943ead502295793f608ad65eb0...
Author: Piotr Caban piotr@codeweavers.com Date: Wed Jul 15 17:34:09 2015 +0200
shell32: Fix SHELL_execute code that removes quote arround file name.
---
dlls/shell32/shlexec.c | 11 +++++------ dlls/shell32/tests/shlexec.c | 11 +++++++++++ 2 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/dlls/shell32/shlexec.c b/dlls/shell32/shlexec.c index 2505981..3196149 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 e3b245a..3d95b41 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