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>2002-06-29 21:26:13 +0400
committerChristopher Faylor <me@cgf.cx>2002-06-29 21:26:13 +0400
commit638180f51f6db54d42f48b4e5daabd159d71484a (patch)
treeefbc3a97d6675f835f9251286c8f557945624901
parent38bc119696ba49314fdb3967767b799a9503a358 (diff)
* environ.cc (spenv::retrieve): Detect return of env_dontadd from cygheap_user
methods. (build_env): Avoid incrementing environment pointer if not actually adding to the environment. That could result in garbage in the environment table. Be more defensive when reallocing envblock.
-rw-r--r--winsup/cygwin/ChangeLog8
-rw-r--r--winsup/cygwin/environ.cc10
2 files changed, 13 insertions, 5 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 627db828f..f314e864f 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,5 +1,13 @@
2002-06-29 Christopher Faylor <cgf@redhat.com>
+ * environ.cc (spenv::retrieve): Detect return of env_dontadd from
+ cygheap_user methods.
+ (build_env): Avoid incrementing environment pointer if not actually
+ adding to the environment. That could result in garbage in the
+ environment table. Be more defensive when reallocing envblock.
+
+2002-06-29 Christopher Faylor <cgf@redhat.com>
+
* uinfo.cc (cygheap_user::test_uid): Return NULL or further tests are
sorta useless.
(cygheap_user::env_domain): Recalculate if name is missing.
diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc
index b86b6b8d1..d0c60edf9 100644
--- a/winsup/cygwin/environ.cc
+++ b/winsup/cygwin/environ.cc
@@ -826,7 +826,7 @@ spenv::retrieve (bool no_envblock, const char *const envname)
/* Calculate (potentially) value for given environment variable. */
p = (cygheap->user.*from_cygheap) (name, namelen);
- if (!p || (no_envblock && !envname))
+ if (!p || (no_envblock && !envname) || (p == env_dontadd))
return env_dontadd;
char *s = (char *) cmalloc (HEAP_1_STR, namelen + strlen (p) + 1);
strcpy (s, name);
@@ -898,10 +898,9 @@ build_env (const char * const *envp, char *&envblock, int &envc,
if (!saw_spenv[i])
{
*dstp = spenvs[i].retrieve (no_envblock);
- if (*dstp && *dstp != env_dontadd)
+ if (*dstp && *dstp != env_dontadd && !no_envblock)
{
- if (!no_envblock)
- tl += strlen (*dstp) + 1;
+ tl += strlen (*dstp) + 1;
dstp++;
}
}
@@ -941,8 +940,9 @@ build_env (const char * const *envp, char *&envblock, int &envc,
/* See if we need to increase the size of the block. */
if (new_tl > tl)
{
+ tl = new_tl + 100;
char *new_envblock =
- (char *) realloc (envblock, 2 + (tl += len + 100));
+ (char *) realloc (envblock, 2 + tl);
/* If realloc moves the block, move `s' with it. */
if (new_envblock != envblock)
{