Katayama Hirofumi MZ : shlwapi: Don' t attempt to un-expand ComputerName in PathUnExpandEnvStrings.

Alexandre Julliard julliard at winehq.org
Fri Feb 23 15:10:24 CST 2018


Module: wine
Branch: master
Commit: 7be8beab68c5074e78c899acac7ccb6eb2f7e22e
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=7be8beab68c5074e78c899acac7ccb6eb2f7e22e

Author: Katayama Hirofumi MZ <katayama.hirofumi.mz at gmail.com>
Date:   Fri Feb 23 18:33:12 2018 +0100

shlwapi: Don't attempt to un-expand ComputerName in PathUnExpandEnvStrings.

Signed-off-by: Thomas Faber <thomas.faber at reactos.org>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/shlwapi/path.c       |  2 --
 dlls/shlwapi/tests/path.c | 18 ++++++++++++++++--
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/dlls/shlwapi/path.c b/dlls/shlwapi/path.c
index 89a3572..ae05381 100644
--- a/dlls/shlwapi/path.c
+++ b/dlls/shlwapi/path.c
@@ -4105,7 +4105,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};
@@ -4142,7 +4141,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/dlls/shlwapi/tests/path.c b/dlls/shlwapi/tests/path.c
index 57fdfdd..91c66b7 100644
--- a/dlls/shlwapi/tests/path.c
+++ b/dlls/shlwapi/tests/path.c
@@ -1463,10 +1463,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;
 
@@ -1476,6 +1477,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");




More information about the wine-cvs mailing list