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

commit af6c5806d5c1ba531a44b19e453c69108e84161d
Author:     Thomas Faber <[email protected]>
AuthorDate: Sat Feb 24 14:15:48 2018 +0100
Commit:     Thomas Faber <[email protected]>
CommitDate: Sat Feb 24 14:18:29 2018 +0100

    [SHLWAPI] Cherry-pick Wine commit 7be8beab68c (Don't attempt to un-expect 
ComputerName in PathUnExpandEnvStrings) by Katayama Hirofumi MZ. CORE-13816
---
 dll/win32/shlwapi/path.c                  |  2 --
 modules/rostests/winetests/shlwapi/path.c | 18 ++++++++++++++++--
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/dll/win32/shlwapi/path.c b/dll/win32/shlwapi/path.c
index 342ef46e54..94472580d9 100644
--- a/dll/win32/shlwapi/path.c
+++ b/dll/win32/shlwapi/path.c
@@ -4120,7 +4120,6 @@ BOOL WINAPI PathUnExpandEnvStringsA(LPCSTR path, LPSTR 
buffer, UINT buf_len)
 
 static const WCHAR allusersprofileW[] = 
{'%','A','L','L','U','S','E','R','S','P','R','O','F','I','L','E','%',0};
 static const WCHAR appdataW[] = {'%','A','P','P','D','A','T','A','%',0};
-static const WCHAR computernameW[] = 
{'%','C','O','M','P','U','T','E','R','N','A','M','E','%',0};
 static const WCHAR programfilesW[] = 
{'%','P','r','o','g','r','a','m','F','i','l','e','s','%',0};
 static const WCHAR systemrootW[] = 
{'%','S','y','s','t','e','m','R','o','o','t','%',0};
 static const WCHAR systemdriveW[] = 
{'%','S','y','s','t','e','m','D','r','i','v','e','%',0};
@@ -4157,7 +4156,6 @@ BOOL WINAPI PathUnExpandEnvStringsW(LPCWSTR path, LPWSTR 
buffer, UINT buf_len)
     struct envvars_map envvars[] = {
         { allusersprofileW, sizeof(allusersprofileW)/sizeof(WCHAR) },
         { appdataW,         sizeof(appdataW)/sizeof(WCHAR)         },
-        { computernameW,    sizeof(computernameW)/sizeof(WCHAR)    },
         { programfilesW,    sizeof(programfilesW)/sizeof(WCHAR)    },
         { systemrootW,      sizeof(systemrootW)/sizeof(WCHAR)      },
         { systemdriveW,     sizeof(systemdriveW)/sizeof(WCHAR)     },
diff --git a/modules/rostests/winetests/shlwapi/path.c 
b/modules/rostests/winetests/shlwapi/path.c
index 6edafc6f9f..78f9090069 100755
--- a/modules/rostests/winetests/shlwapi/path.c
+++ b/modules/rostests/winetests/shlwapi/path.c
@@ -1455,10 +1455,11 @@ static void test_PathUnExpandEnvStrings(void)
     static const WCHAR sysrootW[] = 
{'%','S','y','s','t','e','m','R','o','o','t','%',0};
     static const WCHAR sysdriveW[] = 
{'%','S','y','s','t','e','m','D','r','i','v','e','%',0};
     static const WCHAR nonpathW[] = {'p','a','t','h',0};
+    static const WCHAR computernameW[] = 
{'C','O','M','P','U','T','E','R','N','A','M','E',0};
     static const char sysrootA[] = "%SystemRoot%";
     static const char sysdriveA[] = "%SystemDrive%";
-    WCHAR pathW[MAX_PATH], buffW[MAX_PATH], sysdrvW[3];
-    char path[MAX_PATH], buff[MAX_PATH], sysdrvA[3], envvarA[10];
+    WCHAR pathW[MAX_PATH], buffW[MAX_PATH], sysdrvW[3], envvarW[30];
+    char path[MAX_PATH], buff[MAX_PATH], sysdrvA[3], envvarA[30];
     BOOL ret;
     UINT len;
 
@@ -1468,6 +1469,19 @@ static void test_PathUnExpandEnvStrings(void)
         return;
     }
 
+    /* The value of ComputerName is not a path */
+    ret = GetEnvironmentVariableA("COMPUTERNAME", envvarA, sizeof(envvarA));
+    ok(ret, "got %d\n", ret);
+    SetLastError(0xdeadbeef);
+    ret = pPathUnExpandEnvStringsA(envvarA, buff, sizeof(buff));
+    ok(!ret && GetLastError() == 0xdeadbeef, "got %d, error %d\n", ret, 
GetLastError());
+
+    ret = GetEnvironmentVariableW(computernameW, envvarW, 
sizeof(envvarW)/sizeof(WCHAR));
+    ok(ret, "got %d\n", ret);
+    SetLastError(0xdeadbeef);
+    ret = pPathUnExpandEnvStringsW(envvarW, buffW, 
sizeof(buffW)/sizeof(WCHAR));
+    ok(!ret && GetLastError() == 0xdeadbeef, "got %d, error %d\n", ret, 
GetLastError());
+
     /* something that can't be represented with env var */
     strcpy(path, "somepath_name");
     strcpy(buff, "xx");

Reply via email to