NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: The simple algorithm on rand(3)



On Thu, Aug 11, 2016 at 01:31:59AM -0300, Silas Silva wrote:
> Hi!
> 
> Using zsh's $RANDOM I discovered that it always generated one odd
> number, and then, an even number.  It just feeds srand() with the last
> generated number from rand().

It should not repeatadly call srand(), only once at startup time.

> I was thinking about file a PR, but decided to ask you first if you want
> to keep this algorithm.  Should I report a bug to tell zsh guys and
> other applications to use random(3) instead?

For all practical purposes you should read a byte from /dev/urandom
instead.

Martin


Home | Main Index | Thread Index | Old Index