Source-Changes-HG archive

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

[src/trunk]: src/usr.bin use arc4random



details:   https://anonhg.NetBSD.org/src/rev/697ca68c8c29
branches:  trunk
changeset: 569857:697ca68c8c29
user:      itojun <itojun%NetBSD.org@localhost>
date:      Fri Sep 10 05:34:54 2004 +0000

description:
use arc4random

diffstat:

 usr.bin/cdplay/cdplay.c   |  7 +++----
 usr.bin/shuffle/shuffle.c |  9 +++------
 2 files changed, 6 insertions(+), 10 deletions(-)

diffs (79 lines):

diff -r 6c575cf447bb -r 697ca68c8c29 usr.bin/cdplay/cdplay.c
--- a/usr.bin/cdplay/cdplay.c   Fri Sep 10 04:11:09 2004 +0000
+++ b/usr.bin/cdplay/cdplay.c   Fri Sep 10 05:34:54 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cdplay.c,v 1.27 2003/09/12 00:39:38 christos Exp $     */
+/*     $NetBSD: cdplay.c,v 1.28 2004/09/10 05:36:00 itojun Exp $       */
 
 /*
  * Copyright (c) 1999, 2000, 2001 Andrew Doran.
@@ -40,7 +40,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: cdplay.c,v 1.27 2003/09/12 00:39:38 christos Exp $");
+__RCSID("$NetBSD: cdplay.c,v 1.28 2004/09/10 05:36:00 itojun Exp $");
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -199,7 +199,6 @@
        }
 
        opencd();
-       srandom(time(NULL));
        
        if (argc > 0) {
                interactive = 0;
@@ -712,7 +711,7 @@
                if (fromuser || (rv != CD_AS_PLAY_IN_PROGRESS &&
                    rv != CD_AS_PLAY_PAUSED))
                        trk = h.starting_track +
-                           random() % (h.ending_track - h.starting_track + 1);
+                           arc4random() % (h.ending_track - h.starting_track + 1);
                else
                        return (0);
        } else {
diff -r 6c575cf447bb -r 697ca68c8c29 usr.bin/shuffle/shuffle.c
--- a/usr.bin/shuffle/shuffle.c Fri Sep 10 04:11:09 2004 +0000
+++ b/usr.bin/shuffle/shuffle.c Fri Sep 10 05:34:54 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: shuffle.c,v 1.16 2004/05/18 04:09:21 cube Exp $        */
+/*     $NetBSD: shuffle.c,v 1.17 2004/09/10 05:34:54 itojun Exp $      */
 
 /*
  * Copyright (c) 1998
@@ -33,7 +33,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: shuffle.c,v 1.16 2004/05/18 04:09:21 cube Exp $");
+__RCSID("$NetBSD: shuffle.c,v 1.17 2004/09/10 05:34:54 itojun Exp $");
 #endif /* not lint */
 
 #include <sys/time.h>
@@ -114,7 +114,7 @@
         */
 
        for (j = t - 1; j > 0; j--) {
-               k = random() % (j + 1);
+               k = arc4random() % (j + 1);
                temp = shuffle[j];
                shuffle[j] = shuffle[k];
                shuffle[k] = temp;
@@ -202,7 +202,6 @@
        int i, nflag = 0, pflag = 0, ch;
        char *fname = NULL;
        size_t *shuffle = NULL;
-       struct timeval tv;
        char **lines = NULL;
        size_t nlines = 0, pick = 0;
        char sep = '\n';
@@ -241,8 +240,6 @@
                nlines = argc;
        }
 
-       gettimeofday(&tv, NULL);
-       srandom(getpid() ^ ~getuid() ^ tv.tv_sec ^ tv.tv_usec);
        if (nlines > 0)
                shuffle = get_shuffle(nlines);
 



Home | Main Index | Thread Index | Old Index