History log of /openbsd-current/lib/libc/stdlib/random.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.31 28-Nov-2017 tb

GNU ld has prefixed the contents of .gnu.warning.SYMBOL sections
with "warning: " since 2003, so the messages themselves need not
contain the prefix anymore.

From Scott Cheloha
ok jca, deraadt


Revision tags: OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.30 05-Apr-2016 guenther

Prefer _MUTEX_*LOCK over _THREAD_PRIVATE_MUTEX_*LOCK() when thread-specific
data isn't necessary.

ok mpi@, ok&tweak natano@


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE OPENBSD_5_9_BASE
# 1.29 16-Jan-2015 deraadt

Move to the <limits.h> universe.
review by millert, binary checking process with doug, concept with guenther


# 1.28 16-Dec-2014 sthen

typo; ok deraadt


# 1.27 16-Dec-2014 deraadt

warn for correct symbol


# 1.26 09-Dec-2014 deraadt

improve warnings from rand_r(), rand(), and random()
It may take a few iterations to get the tone right.
previously discussed with millert


# 1.25 08-Dec-2014 deraadt

Change rand(), random(), drand48(), lrand48(), mrand48(), and srand48()
to returning strong random by default, source from arc4random(3).
Parameters to the seeding functions are ignored, and the subsystems remain
in strong random mode. If you wish the standardized deterministic mode,
call srand_deterministic(), srandom_determistic(), srand48_deterministic(),
seed48_deterministic() or lcong48_deterministic() instead.
The re-entrant functions rand_r(), erand48(), nrand48(), jrand48() are
unaffected by this change and remain in deterministic mode (for now).

Verified as a good roadmap forward by auditing 8800 pieces of software.
Roughly 60 pieces of software will need adaptation to request the
deterministic mode.

Violates POSIX and C89, which violate best practice in this century.
ok guenther tedu millert


# 1.24 13-Oct-2014 chl

remove unused variable

ok tedu@


Revision tags: OPENBSD_5_6_BASE
# 1.23 13-Jul-2014 tedu

once srandomdev() is called, switch to using arc4random() but mask off the
high bit as required by posix. wouldn't want to break any standards.
idea and ok deraadt


# 1.22 15-Jun-2014 deraadt

oops, typo. James Hartley is fast at trying -current


# 1.21 15-Jun-2014 deraadt

In srandomdev(), use arc4random_buf() instead of from the kernel.
discussion with matthew


# 1.20 13-Jun-2014 deraadt

use getentropy; from matthew


Revision tags: OPENBSD_5_5_BASE
# 1.19 01-Aug-2013 kettenis

Add linker warnings for rand() and random() and various related functions.

ok deraadt@


Revision tags: OPENBSD_5_4_BASE
# 1.18 15-Mar-2013 tedu

threadsafe random().
reported by ajacoutot and (much earlier, sorry) by Alexey Suslikov


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.17 01-Jun-2012 guenther

Improve standards conformance: ecvt(), fcvt(), gcvt(), mktemp(), ttyslot(),
and valloc() are not in the current version, while posix_memalign() mkstemp(),
and mkdtemp() are, and setstate()'s argument has lost a bogus 'const'.

ok millert@ jmc@ espie@ kettenis@; ports build testing by naddy@


# 1.16 21-Mar-2012 millert

Fix a bug where random() always returns 0 when srandom() is seeded
with 0. Use 1 and not 0 as the first element of the state array,
similar to what glibc does. OK nicm@


Revision tags: OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE
# 1.15 30-Nov-2005 otto

Use sysctl(KERN_ARND) to get n bytes, instead of just 4 at a time
and remove fallback code. If somebody is dumb enough to make the
sysctl fail using systrace, he deserves what he gets. Saves 7 syscalls
on process startup.
looks good miod@ ok deraadt@ tedu@


Revision tags: OPENBSD_3_8_BASE
# 1.14 08-Aug-2005 espie

zap remaining rcsid.

Kill old files that are no longer compiled.

okay theo


# 1.13 30-Mar-2005 pat

ansi + de-register

ok otto deraadt


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE
# 1.12 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_3_BASE
# 1.11 28-Feb-2003 millert

Use int32_t, not long since this deals with 32bit quantities.
Inspired by a change in NetBSD and reported by Jan Johansson.


# 1.10 06-Dec-2002 millert

In srandomdev(), if we can't access /dev/arandom, use the sysctl() instead.
We don't want to use the sysctl() by default since we are reading more
than just a few bytes of entropy when setting up the state.


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE OPENBSD_3_0_BASE OPENBSD_3_1_BASE OPENBSD_3_2_BASE
# 1.9 04-Apr-2000 millert

Fix the leak for real (that's what I get for hacking when i can't sleep).


# 1.8 04-Apr-2000 millert

Fix an fd leak if the read from /dev/arandom fails. Pointed out by
Markus Friedl.


# 1.7 03-Apr-2000 millert

Add srandomdev() from FreeBSD for use by sendmail and others.


Revision tags: OPENBSD_2_3_BASE OPENBSD_2_4_BASE OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.6 07-Feb-1998 millert

More XPG4.2 --
setstate takes a const parameter
don't ever spew to stderr, just return NULL


# 1.5 06-Feb-1998 deraadt

size_t n in initstate(); XPG


Revision tags: OPENBSD_2_0_BASE OPENBSD_2_1_BASE OPENBSD_2_2_BASE
# 1.4 15-Sep-1996 tholo

Remove dead code
Remove unused variables
Silence some warnings
lint(1) is your friend


# 1.3 19-Aug-1996 tholo

Fix RCS ids
Make sure everything uses {SYS,}LIBC_SCCS properly


# 1.2 30-Mar-1996 tholo

Substantially improve random number generation by using the largest prime
that fits inside 32 bits as the denominator; take care not to overflow.
Regenerate initial seed after replacing the generator


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision