delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2019/06/17/10:36:52

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
X-Recipient: djgpp AT delorie DOT com
Date: Mon, 17 Jun 2019 17:33:20 +0300
Message-Id: <83tvcoth73.fsf@gnu.org>
From: "Eli Zaretskii (eliz AT gnu DOT org) [via djgpp AT delorie DOT com]" <djgpp AT delorie DOT com>
To: djgpp AT delorie DOT com
In-reply-to: <qe76u1$1kj8$1@gioia.aioe.org> (message from Rod Pemberton on
Mon, 17 Jun 2019 01:05:38 -0400)
Subject: Re: malloc() returns pointer to already allocated memory
References: <158e5d20-0a90-4beb-de48-da328379d8fb AT gmail DOT com> <qe76u1$1kj8$1 AT gioia DOT aioe DOT org>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

> From: Rod Pemberton <invalid AT lkntrgzxc DOT com>
> Date: Mon, 17 Jun 2019 01:05:38 -0400
> 
> Second problem is you don't call memset() prior to using memory, nor
> free() after you're done using it.  Of course, calling memset() would
> prevent your method of "clobber" detection from working.  But, not
> calling memset() means you don't know if the magic clobber value is:
> a) from you setting it within your program, or
> b) from some random garbage values in memory.

Right.  There's a startup flag that a program could optionally set to
request that allocated memory be filled with a specific fixed value,
then tests for clobbering could work.  See the documentation of
_crt0_startup_flags in the libc manual.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019