Date: Fri, 1 Jun 2007 17:20:06 GMT From: Sean Farley <sean-freebsd@farley.org> To: freebsd-bugs@FreeBSD.org Subject: Re: kern/99826: [libc] [patch] setenv(3)/unsetenv(3) leak memory Message-ID: <200706011720.l51HK6Kt048664@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR kern/99826; it has been noted by GNATS. From: Sean Farley <sean-freebsd@farley.org> To: bug-followup@FreeBSD.org Cc: Subject: Re: kern/99826: [libc] [patch] setenv(3)/unsetenv(3) leak memory Date: Fri, 1 Jun 2007 12:11:13 -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. putenv no longer makes a copy of the input string. d. 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. 6. make universe successfully completed. 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@farley.org
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200706011720.l51HK6Kt048664>