* environ.cc (winenv): Allocate exact amount of space needed for forced windows

environment variable rather than just using MAX_PATH.
This commit is contained in:
Christopher Faylor 2001-09-30 21:37:53 +00:00
parent bb6c3d5832
commit c25c4c5ffc
2 changed files with 11 additions and 3 deletions

View File

@ -1,3 +1,8 @@
Sun Sep 30 17:37:43 2001 Christopher Faylor <cgf@cygnus.com>
* environ.cc (winenv): Allocate exact amount of space needed for forced
windows environment variable rather than just using MAX_PATH.
Sun Sep 30 17:10:18 2001 Christopher Faylor <cgf@cygnus.com>
* Makefile.in: Depend on stamp to ensure rebuilding. Remove stamp file

View File

@ -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
{