From: Glynn Clements <glynn@gclements.plus.com>
To: linux-c-programming@vger.kernel.org
Subject: RE: Into the Void
Date: Wed, 2 Feb 2005 12:15:58 +0000 [thread overview]
Message-ID: <16896.50302.251490.680737@gargle.gargle.HOWL> (raw)
In-Reply-To: <D2AA47A6FB2C1A48AF0526440C0F245CAA3634@monm207.nae.ds.army.mil>
Huber, George K RDECOM CERDEC STCD SRI wrote:
> Well we have not put anything in that memory location yet, and
> as I recall, under Linux any memory is zero-out when returned by malloc to
> help prevent information leakage from one application to another.
Memory contains zeroes when it is first given to the process by the
kernel. Whether or not memory returned from malloc() contains zeroes
depends upon whether that memory has been used previously by the
current process.
At the beginning of a process' life cycle (e.g. at the top of main()),
memory returned from malloc() is likely to contain zeroes.
As time goes by, it becomes increasingly likely that memory returned
from malloc() has previously been allocated, used, then free()d. In
which case, the memory's contents will have been retained; neither
malloc() nor free() themselves fill the memory with zeroes.
If you need to ensure that memory contains zeroes, either use calloc()
(which is defined to fill the memory with zeroes), or fill it yourself
with memset().
--
Glynn Clements <glynn@gclements.plus.com>
next prev parent reply other threads:[~2005-02-02 12:15 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-02-01 15:32 Into the Void Huber, George K RDECOM CERDEC STCD SRI
2005-02-02 12:15 ` Glynn Clements [this message]
-- strict thread matches above, loose matches on Subject: below --
2005-02-02 18:17 Huber, George K RDECOM CERDEC STCD SRI
2005-01-27 17:58 Huber, George K RDECOM CERDEC STCD SRI
2005-01-28 4:36 ` Amit Dang
2005-01-26 16:02 Huber, George K RDECOM CERDEC STCD SRI
2005-01-26 13:45 Jeff.Fellin
2005-01-26 16:11 ` Scott
2005-01-27 4:02 ` Ron Michael Khu
2005-01-27 17:01 ` Scott
2005-01-26 0:09 Scott
2005-01-26 2:18 ` Ron Michael Khu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=16896.50302.251490.680737@gargle.gargle.HOWL \
--to=glynn@gclements.plus.com \
--cc=linux-c-programming@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).