summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--games/fortune/fortune/fortune.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/games/fortune/fortune/fortune.c b/games/fortune/fortune/fortune.c
index 972d8d4..465dd81 100644
--- a/games/fortune/fortune/fortune.c
+++ b/games/fortune/fortune/fortune.c
@@ -188,7 +188,6 @@ char *av[];
exit(find_matches() != 0);
init_prob();
- srandomdev();
do {
get_fort();
} while ((Short_only && fortlen() > SLEN) ||
@@ -982,7 +981,7 @@ get_fort()
if (File_list->next == NULL || File_list->percent == NO_PROB)
fp = File_list;
else {
- choice = random() % 100;
+ choice = arc4random_uniform(100);
DPRINTF(1, (stderr, "choice = %d\n", choice));
for (fp = File_list; fp->percent != NO_PROB; fp = fp->next)
if (choice < fp->percent)
@@ -1002,7 +1001,7 @@ get_fort()
else {
if (fp->next != NULL) {
sum_noprobs(fp);
- choice = random() % Noprob_tbl.str_numstr;
+ choice = arc4random_uniform(Noprob_tbl.str_numstr);
DPRINTF(1, (stderr, "choice = %d (of %u) \n", choice,
Noprob_tbl.str_numstr));
while (choice >= fp->tbl.str_numstr) {
@@ -1044,7 +1043,7 @@ FILEDESC *parent;
int choice;
if (Equal_probs) {
- choice = random() % parent->num_children;
+ choice = arc4random_uniform(parent->num_children);
DPRINTF(1, (stderr, " choice = %d (of %d)\n",
choice, parent->num_children));
for (fp = parent->child; choice--; fp = fp->next)
@@ -1054,7 +1053,7 @@ FILEDESC *parent;
}
else {
get_tbl(parent);
- choice = random() % parent->tbl.str_numstr;
+ choice = arc4random_uniform(parent->tbl.str_numstr);
DPRINTF(1, (stderr, " choice = %d (of %u)\n",
choice, parent->tbl.str_numstr));
for (fp = parent->child; choice >= fp->tbl.str_numstr;
@@ -1143,13 +1142,13 @@ FILEDESC *fp;
#ifdef OK_TO_WRITE_DISK
if ((fd = open(fp->posfile, 0)) < 0 ||
read(fd, &fp->pos, sizeof fp->pos) != sizeof fp->pos)
- fp->pos = random() % fp->tbl.str_numstr;
+ fp->pos = arc4random_uniform(fp->tbl.str_numstr);
else if (fp->pos >= fp->tbl.str_numstr)
fp->pos %= fp->tbl.str_numstr;
if (fd >= 0)
(void) close(fd);
#else
- fp->pos = random() % fp->tbl.str_numstr;
+ fp->pos = arc4random_uniform(fp->tbl.str_numstr);
#endif /* OK_TO_WRITE_DISK */
}
if (++(fp->pos) >= fp->tbl.str_numstr)
OpenPOWER on IntegriCloud