Module: wine Branch: oldstable Commit: a73948bb40f219fb01fd9a8b5c5d5976debd8f17 URL: https://source.winehq.org/git/wine.git/?a=commit;h=a73948bb40f219fb01fd9a8b5...
Author: Jason Edmeades us@edmeades.me.uk Date: Tue Sep 25 08:39:59 2018 +0100
msvcrt: Do not put cmd.exe special environment variables into the environ.
All the special environment variables from the command shell which track directory use are stripped out from the C runtime environ/wenviron.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=45320 Signed-off-by: Jason Edmeades us@edmeades.me.uk Signed-off-by: Piotr Caban piotr@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org (cherry picked from commit 0dcfc97fcbea15037d15dd1021870de25b8382df) Signed-off-by: Michael Stefaniuc mstefani@winehq.org
---
dlls/msvcrt/data.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/dlls/msvcrt/data.c b/dlls/msvcrt/data.c index 06e16a8..f08d9b1 100644 --- a/dlls/msvcrt/data.c +++ b/dlls/msvcrt/data.c @@ -73,7 +73,8 @@ char ** msvcrt_SnapshotOfEnvironmentA(char **blk)
for (ptr = environ_strings; *ptr; ptr += strlen(ptr) + 1) { - count++; + /* Don't count environment variables starting with '=' which are command shell specific */ + if (*ptr != '=') count++; len += strlen(ptr) + 1; } if (blk) @@ -88,7 +89,8 @@ char ** msvcrt_SnapshotOfEnvironmentA(char **blk) memcpy(&blk[count],environ_strings,len); for (ptr = (char*) &blk[count]; *ptr; ptr += strlen(ptr) + 1) { - blk[i++] = ptr; + /* Skip special environment strings set by the command shell */ + if (*ptr != '=') blk[i++] = ptr; } } blk[i] = NULL; @@ -105,7 +107,8 @@ MSVCRT_wchar_t ** msvcrt_SnapshotOfEnvironmentW(MSVCRT_wchar_t **wblk)
for (wptr = wenviron_strings; *wptr; wptr += strlenW(wptr) + 1) { - count++; + /* Don't count environment variables starting with '=' which are command shell specific */ + if (*wptr != '=') count++; len += strlenW(wptr) + 1; } if (wblk) @@ -119,7 +122,8 @@ MSVCRT_wchar_t ** msvcrt_SnapshotOfEnvironmentW(MSVCRT_wchar_t **wblk) memcpy(&wblk[count],wenviron_strings,len * sizeof(MSVCRT_wchar_t)); for (wptr = (MSVCRT_wchar_t*)&wblk[count]; *wptr; wptr += strlenW(wptr) + 1) { - wblk[i++] = wptr; + /* Skip special environment strings set by the command shell */ + if (*wptr != '=') wblk[i++] = wptr; } } wblk[i] = NULL;