summaryrefslogtreecommitdiffstats
path: root/lib/libc
diff options
context:
space:
mode:
authorscf <scf@FreeBSD.org>2007-09-15 21:48:54 +0000
committerscf <scf@FreeBSD.org>2007-09-15 21:48:54 +0000
commit1de7e4d9a46eb669ee95ac6dc8587ebf66cdcfd8 (patch)
treecee9985f40c072714b2597099500c62027b3c0f8 /lib/libc
parent51cad52bc8593dea6307a589845c040347dc3b8e (diff)
downloadFreeBSD-src-1de7e4d9a46eb669ee95ac6dc8587ebf66cdcfd8.zip
FreeBSD-src-1de7e4d9a46eb669ee95ac6dc8587ebf66cdcfd8.tar.gz
Skip rebuilding environ in setenv() only upon reuse of an active variable;
inactive variables should cause a rebuild of environ, otherwise, exec()'d processes will be missing a variable in environ that has been unset then set. Submitted by: Taku Yamamoto <taku@tackymt.homeip.net> Reviewed by: ache Approved by: wes (mentor) Approved by: re (kensmith)
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/stdlib/getenv.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/libc/stdlib/getenv.c b/lib/libc/stdlib/getenv.c
index b6f6121..26de922 100644
--- a/lib/libc/stdlib/getenv.c
+++ b/lib/libc/stdlib/getenv.c
@@ -491,8 +491,8 @@ __setenv(const char *name, size_t nameLen, const char *value, int overwrite)
envVars[envNdx].active = true;
newEnvActive++;
- /* No need to rebuild environ if the variable was reused. */
- if (reuse)
+ /* No need to rebuild environ if an active variable was reused. */
+ if (reuse && newEnvActive == envActive)
return (0);
else
return (__rebuild_environ(newEnvActive));
OpenPOWER on IntegriCloud