Fix misuse of arc4random by using arc4random_uniform.
Noticed by riastradh.
This commit is contained in:
parent
9634b3fd38
commit
3e58855b26
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: shuffle.c,v 1.21 2011/09/16 15:39:29 joerg Exp $ */
|
||||
/* $NetBSD: shuffle.c,v 1.22 2017/02/06 02:26:44 dholland Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1998
|
||||
|
@ -33,7 +33,7 @@
|
|||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: shuffle.c,v 1.21 2011/09/16 15:39:29 joerg Exp $");
|
||||
__RCSID("$NetBSD: shuffle.c,v 1.22 2017/02/06 02:26:44 dholland Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/time.h>
|
||||
|
@ -73,7 +73,7 @@ get_shuffle(size_t t)
|
|||
*/
|
||||
|
||||
for (j = t - 1; j > 0; j--) {
|
||||
k = arc4random() % (j + 1);
|
||||
k = arc4random_uniform(j + 1);
|
||||
temp = shuffle[j];
|
||||
shuffle[j] = shuffle[k];
|
||||
shuffle[k] = temp;
|
||||
|
|
Loading…
Reference in New Issue