Author: VendVend
Date: Jan 2, 2008 08:38
On 1 Gen, 21:44, ross wrote:
> When a chunk of memory is newly allocated it is filled with data from
> whatever program last used it.
Not if the OS prevents data from lacking between different programs.
> Is there anything wrong with using that
> to initialize a PRNG?
Yes.
If you need cryptographical security, then an attacker can predict or
sometimes even choose the content of newly allocated memory.
If you don't need cryptographical security, it's still not good, since
the same initial values might repeat over multiple executions: better
to seed form the system timer in this case.
> (Unless your runtime lib "helpfully" clears new allocations for you, of
> course. Then you might as well just use 0 for a PRNG seed.)
>
> Something like the following.
>
> /*begin C-like pseudo code*/...
|