summaryrefslogtreecommitdiff
path: root/regress/sys
diff options
context:
space:
mode:
authorDamien Miller <djm@cvs.openbsd.org>2008-04-13 00:22:18 +0000
committerDamien Miller <djm@cvs.openbsd.org>2008-04-13 00:22:18 +0000
commitf15cc9e98f102b443a7b1bc97ce7b524d3453c7e (patch)
treecd34ef18f375e585b2843c566e08b7a49da49084 /regress/sys
parentdd3e3e68352b843aef5b3347835e71e9f26a0d92 (diff)
Use arc4random_buf() when requesting more than a single word of output
Use arc4random_uniform() when the desired random number upper bound is not a power of two ok deraadt@ millert@
Diffstat (limited to 'regress/sys')
-rw-r--r--regress/sys/kern/signal-stress/signal-stress.c8
-rw-r--r--regress/sys/sys/tree/rb/rb-test.c4
-rw-r--r--regress/sys/sys/tree/splay/splay-test.c4
3 files changed, 8 insertions, 8 deletions
diff --git a/regress/sys/kern/signal-stress/signal-stress.c b/regress/sys/kern/signal-stress/signal-stress.c
index 9f40e0bb680..61aa23bcd66 100644
--- a/regress/sys/kern/signal-stress/signal-stress.c
+++ b/regress/sys/kern/signal-stress/signal-stress.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: signal-stress.c,v 1.2 2004/08/05 15:06:59 art Exp $ */
+/* $OpenBSD: signal-stress.c,v 1.3 2008/04/13 00:22:17 djm Exp $ */
/*
* Written by Artur Grabowski <art@openbsd.org> 2004 Public Domain.
*/
@@ -140,14 +140,14 @@ main()
* Now all children are ready for action.
* Send the first signals and wait until they all exit.
*/
- kill(pids[arc4random() % nprocs], SIGUSR1);
- kill(pids[arc4random() % nprocs], SIGUSR2);
+ kill(pids[arc4random_uniform(nprocs)], SIGUSR1);
+ kill(pids[arc4random_uniform(nprocs)], SIGUSR2);
/*
* The signal game is running, now insert noise in the process.
*/
for (i = 0; i < nprocs; i++) {
- pid_t pid = pids[arc4random() % nprocs];
+ pid_t pid = pids[arc4random_uniform(nprocs)];
kill(pid, SIGSTOP);
wait_stopped(pid);
kill(pid, SIGCONT);
diff --git a/regress/sys/sys/tree/rb/rb-test.c b/regress/sys/sys/tree/rb/rb-test.c
index f3be4cc0b68..409cc22393a 100644
--- a/regress/sys/sys/tree/rb/rb-test.c
+++ b/regress/sys/sys/tree/rb/rb-test.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rb-test.c,v 1.3 2003/07/31 21:48:10 deraadt Exp $ */
+/* $OpenBSD: rb-test.c,v 1.4 2008/04/13 00:22:17 djm Exp $ */
/*
* Copyright 2002 Niels Provos <provos@citi.umich.edu>
* All rights reserved.
@@ -67,7 +67,7 @@ main(int argc, char **argv)
tmp = malloc(sizeof(struct node));
if (tmp == NULL) err(1, "malloc");
do {
- tmp->key = arc4random() % (MAX-MIN);
+ tmp->key = arc4random_uniform(MAX-MIN);
tmp->key += MIN;
} while (RB_FIND(tree, &root, tmp) != NULL);
if (i == 0)
diff --git a/regress/sys/sys/tree/splay/splay-test.c b/regress/sys/sys/tree/splay/splay-test.c
index 29718302b49..56084a0c71e 100644
--- a/regress/sys/sys/tree/splay/splay-test.c
+++ b/regress/sys/sys/tree/splay/splay-test.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: splay-test.c,v 1.3 2003/07/31 21:48:10 deraadt Exp $ */
+/* $OpenBSD: splay-test.c,v 1.4 2008/04/13 00:22:17 djm Exp $ */
/*
* Copyright 2002 Niels Provos <provos@citi.umich.edu>
* All rights reserved.
@@ -67,7 +67,7 @@ main(int argc, char **argv)
tmp = malloc(sizeof(struct node));
if (tmp == NULL) err(1, "malloc");
do {
- tmp->key = arc4random() % (MAX-MIN);
+ tmp->key = arc4random_uniform(MAX-MIN);
tmp->key += MIN;
} while (SPLAY_FIND(tree, &root, tmp) != NULL);
if (i == 0)