summaryrefslogtreecommitdiffstats
path: root/fortune/strfile
diff options
context:
space:
mode:
authornia <nia@NetBSD.org>2020-07-21 03:05:40 +0000
committernia <nia@NetBSD.org>2020-07-21 03:05:40 +0000
commit71a4bdd386813a0bd96c205cf36b3faf3b1ea0e1 (patch)
tree6341cc28ea21fd5de737d174da7132dd4cd345c6 /fortune/strfile
parent28db4ccb3e2ee071d561e6ab9f075e7deb65fdb6 (diff)
downloadbsdgames-darwin-71a4bdd386813a0bd96c205cf36b3faf3b1ea0e1.tar.gz
bsdgames-darwin-71a4bdd386813a0bd96c205cf36b3faf3b1ea0e1.tar.zst
bsdgames-darwin-71a4bdd386813a0bd96c205cf36b3faf3b1ea0e1.zip
fortune: arc4random_uniform for better uniform values than random() % ...
Diffstat (limited to 'fortune/strfile')
-rw-r--r--fortune/strfile/strfile.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/fortune/strfile/strfile.c b/fortune/strfile/strfile.c
index 891c77dd..29298955 100644
--- a/fortune/strfile/strfile.c
+++ b/fortune/strfile/strfile.c
@@ -1,4 +1,4 @@
-/* $NetBSD: strfile.c,v 1.40 2020/04/30 12:32:26 christos Exp $ */
+/* $NetBSD: strfile.c,v 1.41 2020/07/21 03:05:40 nia Exp $ */
/*-
* Copyright (c) 1989, 1993
@@ -47,7 +47,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 1993\
#if 0
static char sccsid[] = "@(#)strfile.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: strfile.c,v 1.40 2020/04/30 12:32:26 christos Exp $");
+__RCSID("$NetBSD: strfile.c,v 1.41 2020/07/21 03:05:40 nia Exp $");
#endif
#endif /* not lint */
#endif /* __NetBSD__ */
@@ -438,8 +438,6 @@ randomize(void)
off_t tmp;
off_t *sp;
- srandom((int)(time(NULL) + getpid()));
-
Tbl.str_flags |= STR_RANDOM;
cnt = Tbl.str_numstr;
@@ -448,7 +446,7 @@ randomize(void)
*/
for (sp = Seekpts; cnt > 0; cnt--, sp++) {
- i = random() % cnt;
+ i = arc4random_uniform(cnt);
tmp = sp[0];
sp[0] = sp[i];
sp[i] = tmp;