Date: 07 Aug 1998 21:32:31 +0200 From: dag-erli@ifi.uio.no (Dag-Erling Coidan =?iso-8859-1?Q?Sm=F8rgrav?= ) To: Archie Cobbs <archie@whistle.com> Cc: wollman@khavrinen.lcs.mit.edu (Garrett Wollman), freebsd-current@FreeBSD.ORG, bde@zeta.org.au, dg@root.com Subject: Re: memory leaks in libc Message-ID: <xzpogtw37w0.fsf@hrotti.ifi.uio.no> In-Reply-To: Archie Cobbs's message of "Fri, 7 Aug 1998 10:37:26 -0700 (PDT)" References: <199808071737.KAA29957@bubba.whistle.com>
next in thread | previous in thread | raw e-mail | index | archive | help
Archie Cobbs <archie@whistle.com> writes: > Garrett Wollman writes: > > No, you've missed the point entirely. *Any program which does enough > > playing around with the environment to be harmed by this memory leak > > is using a totally inappropriate interface.* > I disagree with that statement! And I base my disagreement not on > conjecture but on experience. There is only one situation in which you need to change the environment: fork-and-exec, in which case it is trivial to construct a fresh environment for your child process in a safe manner. If you're not fork-and-execing, use program variables instead (which you initialize with getenv()). If you're writing a shell and need to keep track of lots of environment variables and pass them to your children, you're in both situations at once; use a hash table for quick lookup (you'll need it for variable substitution in command lines) and pass execve() a list of pointers to the contents of your hash table. > How can it possibly do this? The only way to get strftime() to > acknowledge a change in timezone is to do something like this: > > unsetenv("TZ"); > tzset(); > setenv("TZ", "/etc/localtime", 1); > tzset(); Then strftime() should be taken out and shot. Arguably, so should setenv(), but fixing setenv() will only hide the symptoms of bad programming practice. That said, I don't really see any reason *not* to commit your setenv() replacement, if it works properly. It's just that there aren't really any arguments *for* the commit, either. DES -- Dag-Erling Smørgrav - dag-erli@ifi.uio.no To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?xzpogtw37w0.fsf>