Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 27 Jul 2011 22:44:45 +1000
From:      Sean <sean@gothic.net.au>
To:        grarpamp <grarpamp@gmail.com>
Cc:        freebsd-security@freebsd.org
Subject:   Re: Malloc -Z
Message-ID:  <CAF3EE36-98E2-4265-A1C9-DA9671AB89C5@gothic.net.au>
In-Reply-To: <CAD2Ti2_xCSzjB6eC0pUU6DHj7OSsmE_E4ikgDRx=CU3un64LoA@mail.gmail.com>
References:  <CAD2Ti2_xCSzjB6eC0pUU6DHj7OSsmE_E4ikgDRx=CU3un64LoA@mail.gmail.com>

index | next in thread | previous in thread | raw e-mail


On 27/07/2011, at 4:49 PM, grarpamp wrote:

> Was reading malloc(3) while chasing corruption suspects.
> Does the presence of -Z imply that without it, programs
> can be allocated dirty (non-zeroed) memory?
> If so, it seems running with -Z would be prudent if one cares.
> Therefore, what is the rough percent performance
> impact of -Z compared to default malloc?
> 

malloc(3) has never provided zeroed memory. If you need zeroed memory in C, you either need to zero it yourself using memset(3), or use calloc(3).

It's been part of the language standard for over 20 years now, and is the same in that regard on every platform that provides malloc(3).

What would be prudent as a developer (and is the default in CURRENT I believe) is to use J - it enforces the "memory from malloc(3) is not guaranteed to be zeroed." by specifically setting it to non-zero.


> Bonus:
> What would be needed to make the useful streams:
> /dev/one
> /dev/10
> /dev/01
> In addition to /dev/zero.
> _______________________________________________
> freebsd-security@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-security
> To unsubscribe, send any mail to "freebsd-security-unsubscribe@freebsd.org"



help

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAF3EE36-98E2-4265-A1C9-DA9671AB89C5>