[BusyBox] hush environment variables
Larry Doolittle
ldoolitt at recycle.lbl.gov
Fri May 4 12:30:47 UTC 2001
Evin discovered:
> Currently on my system (with gnu libc 2.1.3) doing export foo=blue
> doesn't work in CVS hush.
> The problem seems to be that the data passed to putenv is overwritten
> later, so the environment data no longer contains the variable when I
> try to use it.
Evin's analysis and patch look correct to me.
> Strangely things appear to work fine in lash even though the
> builtin_export funcions are basically the same in both lash and hush.
hush and lash handle argv[] very differently. Either lash
leaks memory like a sieve, or you got lucky on your tests.
I suspect the latter.
> The following patch makes it work here. Does it create a small memory
> leak? Is there a better way?
A memory leak would show up if someone says:
$ export foo=blue
$ export foo=green
$ export foo=red
I doubt if putenv(3) is smart enough to free() the "foo=blue"
and "foo=green" strings. lash and hush are certainly not that
smart. I don't recommend spending effort on a fix. The two
exceptions would be if:
* it kills your application
* you add local variable support at the same time
- Larry
More information about the busybox
mailing list