From 1de7e4d9a46eb669ee95ac6dc8587ebf66cdcfd8 Mon Sep 17 00:00:00 2001 From: scf Date: Sat, 15 Sep 2007 21:48:54 +0000 Subject: 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 Reviewed by: ache Approved by: wes (mentor) Approved by: re (kensmith) --- lib/libc/stdlib/getenv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/libc/stdlib/getenv.c') 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)); -- cgit v1.1