Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2001-10-01 01:37:53 +0400
committerChristopher Faylor <me@cgf.cx>2001-10-01 01:37:53 +0400
commitc25c4c5ffcc8749993cc786b8a559f9d2e0e4684 (patch)
tree11c96729b27523094aa2df06974617bf35328a79 /winsup/cygwin/environ.cc
parentbb6c3d5832a1ec56ebd9edcc5fc90e150e09f745 (diff)
* environ.cc (winenv): Allocate exact amount of space needed for forced windows
environment variable rather than just using MAX_PATH.
Diffstat (limited to 'winsup/cygwin/environ.cc')
-rw-r--r--winsup/cygwin/environ.cc9
1 files changed, 6 insertions, 3 deletions
diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc
index 1be0b79b5..c1529e704 100644
--- a/winsup/cygwin/environ.cc
+++ b/winsup/cygwin/environ.cc
@@ -806,14 +806,17 @@ winenv (const char * const *envp, int keep_posix)
saw_forced_winenv[i] = strncasematch (forced_winenv_vars[i], *srcp, len);
}
+ char dum[1];
for (int i = 0; forced_winenv_vars[i]; i++)
if (!saw_forced_winenv[i])
{
- len = strlen (forced_winenv_vars[i]);
- p = (char *) alloca (len + MAX_PATH + 1);
+ int namelen = strlen (forced_winenv_vars[i]) + 1;
+ int vallen = GetEnvironmentVariable (forced_winenv_vars[i], dum, 0) + 1;
+ p = (char *) alloca (namelen + vallen);
strcpy (p, forced_winenv_vars[i]);
strcat (p, "=");
- if (!GetEnvironmentVariable (forced_winenv_vars[i], p + len + 1, MAX_PATH))
+ if (!GetEnvironmentVariable (forced_winenv_vars[i], p + namelen,
+ vallen + 1))
debug_printf ("warning: %s not present in environment", *srcp);
else
{