diff options
author | tb <tb@cvs.openbsd.org> | 2015-12-16 19:44:43 +0000 |
---|---|---|
committer | tb <tb@cvs.openbsd.org> | 2015-12-16 19:44:43 +0000 |
commit | 0b955f2070e0f2fcef1b75b648c9baeac843e943 (patch) | |
tree | cdbfba1f52b37cab4aefcb8f9cb2d8057bdd306f /usr.bin/awk/run.c | |
parent | 7dbbe04a5f8feba24418d549c75d083c06ccb53b (diff) |
Remove modulo bias in random number generator.
Diff from Matthew Martin, rewieved by deraadt@ and me.
ok deraadt@, millert@
Diffstat (limited to 'usr.bin/awk/run.c')
-rw-r--r-- | usr.bin/awk/run.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/usr.bin/awk/run.c b/usr.bin/awk/run.c index 8f433ea7b7f..26825fd6a42 100644 --- a/usr.bin/awk/run.c +++ b/usr.bin/awk/run.c @@ -1,4 +1,4 @@ -/* $OpenBSD: run.c,v 1.39 2015/09/05 22:07:10 deraadt Exp $ */ +/* $OpenBSD: run.c,v 1.40 2015/12/16 19:44:42 tb Exp $ */ /**************************************************************** Copyright (C) Lucent Technologies 1997 All Rights Reserved @@ -1581,7 +1581,7 @@ Cell *bltin(Node **a, int n) /* builtin functions. a[0] is type, a[1] is arg lis u = (Awkfloat) system(getsval(x)) / 256; /* 256 is unix-dep */ break; case FRAND: - u = (Awkfloat) (random() % RAND_MAX) / RAND_MAX; + u = (Awkfloat) (random() & RAND_MAX) / ((u_int)RAND_MAX + 1); break; case FSRAND: if (isrec(x)) { /* no argument provided */ |