Carlo Bramini : hhctrl.ocx: Expand environment vars in file name.

Alexandre Julliard julliard at winehq.org
Mon Aug 26 15:47:27 CDT 2019


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

Author: Carlo Bramini <carlo.bramix at libero.it>
Date:   Sat Aug 24 20:50:24 2019 +0200

hhctrl.ocx: Expand environment vars in file name.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47379
Signed-off-by: Carlo Bramini <carlo_bramini at users.sourceforge.net>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/hhctrl.ocx/hhctrl.c | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/dlls/hhctrl.ocx/hhctrl.c b/dlls/hhctrl.ocx/hhctrl.c
index e757167..6a98ae4 100644
--- a/dlls/hhctrl.ocx/hhctrl.c
+++ b/dlls/hhctrl.ocx/hhctrl.c
@@ -97,7 +97,7 @@ static const char *command_to_string(UINT command)
 #undef X
 }
 
-static BOOL resolve_filename(const WCHAR *filename, WCHAR *fullname, DWORD buflen, WCHAR **index, WCHAR **window)
+static BOOL resolve_filename(const WCHAR *env_filename, WCHAR *fullname, DWORD buflen, WCHAR **index, WCHAR **window)
 {
     const WCHAR *extra;
     WCHAR chm_file[MAX_PATH];
@@ -106,12 +106,25 @@ static BOOL resolve_filename(const WCHAR *filename, WCHAR *fullname, DWORD bufle
     static const WCHAR delimW[] = {':',':',0};
     static const WCHAR delim2W[] = {'>',0};
 
-    filename = skip_schema(filename);
+    DWORD env_len;
+    WCHAR *filename;
+
+    env_filename = skip_schema(env_filename);
 
     /* the format is "helpFile[::/index][>window]" */
     if (index) *index = NULL;
     if (window) *window = NULL;
 
+    env_len = ExpandEnvironmentStringsW(env_filename, NULL, 0);
+    if (!env_len)
+        return 0;
+
+    filename = heap_alloc(env_len * sizeof(WCHAR));
+    if (filename == NULL)
+        return 0;
+
+    ExpandEnvironmentStringsW(env_filename, filename, env_len);
+
     extra = wcsstr(filename, delim2W);
     if (extra)
     {
@@ -140,6 +153,9 @@ static BOOL resolve_filename(const WCHAR *filename, WCHAR *fullname, DWORD bufle
         lstrcatW(fullname, helpW);
         lstrcatW(fullname, filename);
     }
+
+    heap_free(filename);
+
     return (GetFileAttributesW(fullname) != INVALID_FILE_ATTRIBUTES);
 }
 




More information about the wine-cvs mailing list