setenv() patch for POSIX and memory leak
- From: "Sean C. Farley" <sean-freebsd@xxxxxxxxxx>
- Date: Tue, 29 May 2007 18:00:09 -0500 (CDT)
I have completed a new version[1] of a replacement (kern/99826[1]) for
getenv/setenv/putenv/unsetenv(). A patch against CURRENT that updates
libc and a few base utilities can be found here[2]. I built it and ran
it successfully.
Notes:
1. Fixes memory leak as noted in BUGS section for setenv(3).
Example of the leak:
setenv("TZ", "CDT", 1);
setenv("TZ", "YEKST", 1); // Leaks
setenv("TZ", "CDT", 1);
setenv("TZ", "YEKST", 1); // Leaks
2. Converts all calls to POSIX from historic BSD API.
a. unsetenv returns an int.
b. putenv takes a char * instead of const char *.
c. errno is set appropriately for POSIX. Exceptions involve bad
environ variable and internal initialization code. These both set
errno to EFAULT.
3. Several patches to base utilities to handle the POSIX changes are
from Andrey Chernov's previous commit. A few I re-wrote to use
setenv() instead of putenv(). Yes, I dislike putenv(). :)
4. A new regression module to test these functions was written. It also
can be used to test the performance. I found performance to be
on-par or better. It is found in tools/regression/environment.
5. Man page could use more work to match all the changes.
Thank you to Andrey and others for your help in proofreading several
iterations of the code.
Sean
1. http://www.freebsd.org/cgi/query-pr.cgi?pr=kern/99826
2. http://www.farley.org/freebsd/tmp/setenv/setenv-9/
3. http://www.farley.org/freebsd/tmp/setenv/setenv-9/setenv.diff
--
sean-freebsd@xxxxxxxxxx
_______________________________________________
freebsd-current@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscribe@xxxxxxxxxxx"
- Follow-Ups:
- Re: setenv() patch for POSIX and memory leak
- From: Sean C. Farley
- Re: setenv() patch for POSIX and memory leak
- Prev by Date: Re: Xorg port problem?
- Next by Date: MFC plans for TSO and VLAN??
- Previous by thread: WITHOUT_PROFILE no longer honored?
- Next by thread: Re: setenv() patch for POSIX and memory leak
- Index(es):
Relevant Pages
- Re: cvs commit: src/usr.sbin/sysinstall main.c
... If it wasn't obvious from my post, I think that the POSIX putenvis ... most
of the software in ports probably runs more often on Linux than ... :> Solaris (judging
by Open Solaris's putenv() implementation). ... This breaks Linux and Solaris and
POSIX as well. ... (freebsd-arch) - Re: cvs commit: src/usr.sbin/sysinstall main.c
... If it wasn't obvious from my post, I think that the POSIX putenvis ... most
of the software in ports probably runs more often on Linux than ... :> Solaris (judging
by Open Solaris's putenv() implementation). ... This breaks Linux and Solaris and
POSIX as well. ... (freebsd-arch) - Re: HEADS DOWN
... Would POSIX or BSD be preferred? ... in the POSIX spec but makes it closer to
setenv() in its errors. ... How about dropping putenv() altogether? ... empty
string and string without '=') on the string given to it. ... (freebsd-arch) - Re: HEADS DOWN
... : POSIX version. ... Would POSIX or BSD be preferred? ... added
some checking to putenv() that is not mentioned in the POSIX ... spec but makes it closer
to setenv() in its errors. ... (freebsd-arch) - Re: HEADS DOWN
... : POSIX version. ... Would POSIX or BSD be preferred? ... added
some checking to putenv() that is not mentioned in the POSIX ... spec but makes it closer
to setenv() in its errors. ... (freebsd-current)