diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2015-01-14 10:31:14 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2015-01-14 10:31:14 +0000 |
commit | 63716e7d421edf678fc432a44fe27e2b91c84f05 (patch) | |
tree | 6cc811f0a17aecd1e792aef28d3d2d2cfd2a118d /winsup | |
parent | f91272b8c2061c1c2371aa415ad3bb0ce29a19f8 (diff) | |
download | cygnal-63716e7d421edf678fc432a44fe27e2b91c84f05.tar.gz cygnal-63716e7d421edf678fc432a44fe27e2b91c84f05.tar.bz2 cygnal-63716e7d421edf678fc432a44fe27e2b91c84f05.zip |
* environ.cc (build_env): When merging the user's Windows environment,
explicitely skip the variables needing conversion to avoid collisions.
Extend comment to explain.
Diffstat (limited to 'winsup')
-rw-r--r-- | winsup/cygwin/ChangeLog | 6 | ||||
-rw-r--r-- | winsup/cygwin/environ.cc | 22 |
2 files changed, 25 insertions, 3 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 3e27499ba..3c3865cf7 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,9 @@ +2015-01-14 Corinna Vinschen <corinna@vinschen.de> + + * environ.cc (build_env): When merging the user's Windows environment, + explicitely skip the variables needing conversion to avoid collisions. + Extend comment to explain. + 2015-01-13 Corinna Vinschen <corinna@vinschen.de> * uinfo.cc (pwdgrp::fetch_account_from_windows): Drop code from diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc index e9c92c42e..4813e02fe 100644 --- a/winsup/cygwin/environ.cc +++ b/winsup/cygwin/environ.cc @@ -1071,9 +1071,11 @@ build_env (const char * const *envp, PWCHAR &envblock, int &envc, sys_wcstombs_alloc (&winenv[winnum], HEAP_NOTHEAP, var); } DestroyEnvironmentBlock (cwinenv); - /* Eliminate variables which are already available in envp. The windows - env is sorted, so we can use bsearch. We're doing this first step, - so the following code doesn't allocate too much memory. */ + /* Eliminate variables which are already available in envp, as well as + the small set of crucial variables needing POSIX conversion and + potentially collide. The windows env is sorted, so we can use + bsearch. We're doing this first step, so the following code doesn't + allocate too much memory. */ if (winenv) { for (srcp = envp; *srcp; srcp++) @@ -1091,6 +1093,20 @@ build_env (const char * const *envp, PWCHAR &envblock, int &envc, --winnum; } } + for (char **elem = winenv; *elem; elem++) + { + if (match_first_char (*elem, WC)) + for (int i = 0; conv_envvars[i].name != NULL; i++) + if (strncmp (*elem, conv_envvars[i].name, + conv_envvars[i].namelen) == 0) + { + free (*elem); + memmove (elem, elem + 1, + (winnum - (elem - winenv)) * sizeof *elem); + --winnum; + --elem; + } + } } } |