Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/shuffle Fix misuse of arc4random by using arc4random...



details:   https://anonhg.NetBSD.org/src/rev/f202bc0ced36
branches:  trunk
changeset: 821444:f202bc0ced36
user:      dholland <dholland%NetBSD.org@localhost>
date:      Mon Feb 06 02:26:44 2017 +0000

description:
Fix misuse of arc4random by using arc4random_uniform.
Noticed by riastradh.

diffstat:

 usr.bin/shuffle/shuffle.c |  6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diffs (27 lines):

diff -r b9e1be060ccd -r f202bc0ced36 usr.bin/shuffle/shuffle.c
--- a/usr.bin/shuffle/shuffle.c Sun Feb 05 20:08:35 2017 +0000
+++ b/usr.bin/shuffle/shuffle.c Mon Feb 06 02:26:44 2017 +0000
@@ -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 @@
         */
 
        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;



Home | Main Index | Thread Index | Old Index