From owner-freebsd-current Thu Aug 6 05:26:23 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id FAA26429 for freebsd-current-outgoing; Thu, 6 Aug 1998 05:26:23 -0700 (PDT) (envelope-from owner-freebsd-current@FreeBSD.ORG) Received: from haldjas.folklore.ee (Haldjas.folklore.ee [193.40.6.121]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id FAA26424 for ; Thu, 6 Aug 1998 05:26:20 -0700 (PDT) (envelope-from narvi@haldjas.folklore.ee) Received: from haldjas.folklore.ee (haldjas.folklore.ee [172.17.2.1] (may be forged)) by haldjas.folklore.ee (8.8.8/8.8.4) with SMTP id PAA24176; Thu, 6 Aug 1998 15:24:08 +0300 (EEST) Date: Thu, 6 Aug 1998 15:24:08 +0300 (EEST) From: Narvi To: Bruce Evans cc: dg@root.com, freebsd@xaa.iae.nl, freebsd-current@FreeBSD.ORG Subject: Re: memory leaks in libc In-Reply-To: <199808061110.VAA13616@godzilla.zeta.org.au> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Thu, 6 Aug 1998, Bruce Evans wrote: > > The problem with fixing setenv() is that you don't know if a pointer was > >malloced, allocated from the env area above the stack, points to read-only > >text, points to a static data buffer, etc. There really is no way to know > >for sure, so you can't free the memory. > > Yo can know if you malloced it in a previous call to putenv() or setenv(). > > Bruce So we could: a) allocate a bit more memory than needed b) set the environment string c) end it with zero d) append a certain token after the end of the string saying "ok to free() me" to anyone knowing what to look at? But couldn't a string end at the end of allocated area so that by peeking behind the final zero we will sometimes cause a SIGSEV? Sander There is no love, no good, no happiness and no future - all these are just illusions. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message