* environ.cc (build_env): When merging the user's Windows environment,
explicitely skip the variables needing conversion to avoid collisions. Extend comment to explain.
This commit is contained in:
		| @@ -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> | 2015-01-13  Corinna Vinschen  <corinna@vinschen.de> | ||||||
|  |  | ||||||
| 	* uinfo.cc (pwdgrp::fetch_account_from_windows): Drop code from | 	* uinfo.cc (pwdgrp::fetch_account_from_windows): Drop code from | ||||||
|   | |||||||
| @@ -1071,9 +1071,11 @@ build_env (const char * const *envp, PWCHAR &envblock, int &envc, | |||||||
| 	    sys_wcstombs_alloc (&winenv[winnum], HEAP_NOTHEAP, var); | 	    sys_wcstombs_alloc (&winenv[winnum], HEAP_NOTHEAP, var); | ||||||
| 	} | 	} | ||||||
|       DestroyEnvironmentBlock (cwinenv); |       DestroyEnvironmentBlock (cwinenv); | ||||||
|       /* Eliminate variables which are already available in envp.  The windows |       /* Eliminate variables which are already available in envp, as well as | ||||||
| 	 env is sorted, so we can use bsearch.  We're doing this first step, | 	 the small set of crucial variables needing POSIX conversion and | ||||||
| 	 so the following code doesn't allocate too much memory. */ | 	 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) |       if (winenv) | ||||||
| 	{ | 	{ | ||||||
| 	  for (srcp = envp; *srcp; srcp++) | 	  for (srcp = envp; *srcp; srcp++) | ||||||
| @@ -1091,6 +1093,20 @@ build_env (const char * const *envp, PWCHAR &envblock, int &envc, | |||||||
| 		  --winnum; | 		  --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; | ||||||
|  | 		    } | ||||||
|  | 	    } | ||||||
| 	} | 	} | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user