From f1fa722f80fc7961bf5792110e8111a6319fcee7 Mon Sep 17 00:00:00 2001 From: cgf Date: Sun, 30 Sep 2001 21:37:53 +0000 Subject: [PATCH] * environ.cc (winenv): Allocate exact amount of space needed for forced windows environment variable rather than just using MAX_PATH. --- winsup/cygwin/ChangeLog | 5 +++++ winsup/cygwin/environ.cc | 9 ++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 8d0483da95..bd81827379 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,8 @@ +Sun Sep 30 17:37:43 2001 Christopher Faylor + + * 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 * Makefile.in: Depend on stamp to ensure rebuilding. Remove stamp file diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc index 1be0b79b5a..c1529e704c 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 { -- 2.11.0