Date: Sat, 14 Jul 2007 06:26:38 +0400 From: Andrey Chernov <ache@nagual.pp.ru> To: "Sean C. Farley" <scf@FreeBSD.org>, freebsd-current <freebsd-current@FreeBSD.org> Subject: Re: Environment handling broken in /bin/sh with changes to t,set,put}env() Message-ID: <20070714022638.GA25256@nagual.pp.ru> In-Reply-To: <20070714014319.GA24701@nagual.pp.ru> References: <20070713162742.GA16260@nagual.pp.ru> <20070713142545.K26096@thor.farley.org> <20070713202433.GA19856@nagual.pp.ru> <20070713203915.GA20270@nagual.pp.ru> <20070713171942.Q26096@thor.farley.org> <20070713224608.GB21695@nagual.pp.ru> <20070713184543.A26096@thor.farley.org> <20070714004116.GA22909@nagual.pp.ru> <20070713200048.X26971@thor.farley.org> <20070714014319.GA24701@nagual.pp.ru>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, Jul 14, 2007 at 05:43:20AM +0400, Andrey Chernov wrote:
> On Fri, Jul 13, 2007 at 08:10:33PM -0500, Sean C. Farley wrote:
> >> It ends up with environ = NULL; because envVarsTotal initialized to 0
> >> i.e. makes from "environ[0] == NULL" case "environ == NULL" case
> >> which is different thing.
> >
> > I changed it to return (0) if either environ or environ[0] equal NULL.
> > The SaveEnviron label is removed as well as the (envVarsTotal > 0)
> > check.
>
> Looks OK.
BTW, I fear about another place on this matter, merge_environ().
Look at this example:
... some setenv's called before
nenv[0] = NULL;
environ = nenv;
unsetenv("NONEXISTEN");
What happens to environ pointer _after_ that?
unsetenv() leads to environ = watchEnviron; in the merge_environ() but
this environ is never rebuilded because no single setenv() is called from
merge_environ() and no rebuild_environ() is called from unsetenv() due to
"NONEXISTENT" value not found. It means reassigned environ inherits stale
pointers from non-rebuilded watchEnviron which not equals to
environ[0] == NULL
Did I miss something?
The same about
environ = NULL;
unsetenv("NONEXISTEN");
--
http://ache.pp.ru/
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20070714022638.GA25256>
