Module Name:    src
Committed By:   dholland
Date:           Mon Feb  6 02:26:44 UTC 2017

Modified Files:
        src/usr.bin/shuffle: shuffle.c

Log Message:
Fix misuse of arc4random by using arc4random_uniform.
Noticed by riastradh.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/usr.bin/shuffle/shuffle.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/shuffle/shuffle.c
diff -u src/usr.bin/shuffle/shuffle.c:1.21 src/usr.bin/shuffle/shuffle.c:1.22
--- src/usr.bin/shuffle/shuffle.c:1.21	Fri Sep 16 15:39:29 2011
+++ src/usr.bin/shuffle/shuffle.c	Mon Feb  6 02:26:44 2017
@@ -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;

Reply via email to