https://git.reactos.org/?p=reactos.git;a=commitdiff;h=766d04d937896699a5a0ff6a6e4a7797195856d0

commit 766d04d937896699a5a0ff6a6e4a7797195856d0
Author:     Katayama Hirofumi MZ <katayama.hirofumi...@gmail.com>
AuthorDate: Fri Aug 2 04:03:25 2024 +0900
Commit:     GitHub <nore...@github.com>
CommitDate: Fri Aug 2 04:03:25 2024 +0900

    [SHELL32] shlexec: Do not expand without SEE_MASK_DOENVSUBST (#7206)
    
    JIRA issue: N/A
    Don't expand the application name
    unless SEE_MASK_DOENVSUBST
    is not specified.
---
 dll/win32/shell32/shlexec.cpp | 20 +-------------------
 1 file changed, 1 insertion(+), 19 deletions(-)

diff --git a/dll/win32/shell32/shlexec.cpp b/dll/win32/shell32/shlexec.cpp
index c5c121eaf18..6134aaf311b 100644
--- a/dll/win32/shell32/shlexec.cpp
+++ b/dll/win32/shell32/shlexec.cpp
@@ -2068,7 +2068,7 @@ static BOOL SHELL_execute(LPSHELLEXECUTEINFOW sei, 
SHELL_ExecuteW32 execfunc)
         TRACE("-- idlist=%p (%s)\n", sei_tmp.lpIDList, 
debugstr_w(wszApplicationName));
     }
 
-    if (sei_tmp.fMask & SEE_MASK_DOENVSUBST)
+    if ((sei_tmp.fMask & SEE_MASK_DOENVSUBST) && 
!StrIsNullOrEmpty(sei_tmp.lpFile))
     {
         WCHAR *tmp = expand_environment(sei_tmp.lpFile);
         if (tmp)
@@ -2076,13 +2076,6 @@ static BOOL SHELL_execute(LPSHELLEXECUTEINFOW sei, 
SHELL_ExecuteW32 execfunc)
             wszApplicationName.Attach(tmp);
             sei_tmp.lpFile = wszApplicationName;
         }
-
-        tmp = expand_environment(sei_tmp.lpDirectory);
-        if (tmp)
-        {
-            wszDirAlloc.Attach(tmp);
-            sei_tmp.lpDirectory = wszDir = wszDirAlloc;
-        }
     }
 
     if ((sei_tmp.fMask & SEE_MASK_INVOKEIDLIST) == SEE_MASK_INVOKEIDLIST)
@@ -2095,7 +2088,6 @@ static BOOL SHELL_execute(LPSHELLEXECUTEINFOW sei, 
SHELL_ExecuteW32 execfunc)
         }
     }
 
-
     if (ERROR_SUCCESS == ShellExecute_FromContextMenuHandlers(&sei_tmp))
     {
         sei->hInstApp = (HINSTANCE) 33;
@@ -2156,16 +2148,6 @@ static BOOL SHELL_execute(LPSHELLEXECUTEINFOW sei, 
SHELL_ExecuteW32 execfunc)
         wszApplicationName.Attach(buf.Detach());
         sei_tmp.lpFile = wszApplicationName;
     }
-    else /* or expand environment strings (not both!) */
-    {
-        LPWSTR tmp = expand_environment(sei_tmp.lpFile);
-        if (tmp)
-        {
-            wszApplicationName.Attach(tmp);
-            /* appKnownSingular unmodified */
-            sei_tmp.lpFile = wszApplicationName;
-        }
-    }
 
     /* Else, try to execute the filename */
     TRACE("execute: %s,%s,%s\n", debugstr_w(wszApplicationName), 
debugstr_w(wszParameters), debugstr_w(wszDir));

Reply via email to