diff options
author | Ted Unangst <tedu@cvs.openbsd.org> | 2014-12-31 15:45:58 +0000 |
---|---|---|
committer | Ted Unangst <tedu@cvs.openbsd.org> | 2014-12-31 15:45:58 +0000 |
commit | 1d3d1862be9cc4bd85c83c30891898759251b594 (patch) | |
tree | d0f8947bf8b5fe6b641ece68bb415758097764e6 | |
parent | e67f58aa35f31c23ce54efccc2c4167de45873a5 (diff) |
adventure requires deterministic random for its internal data
"obfuscation" scheme to work (words fail me), but we can use arc4random
for the in game fun. from theo buehler
-rw-r--r-- | games/adventure/init.c | 7 | ||||
-rw-r--r-- | games/adventure/setup.c | 4 | ||||
-rw-r--r-- | games/adventure/wizard.c | 7 |
3 files changed, 11 insertions, 7 deletions
diff --git a/games/adventure/init.c b/games/adventure/init.c index 6de5b774b9d..6060368fbdd 100644 --- a/games/adventure/init.c +++ b/games/adventure/init.c @@ -1,4 +1,4 @@ -/* $OpenBSD: init.c,v 1.12 2014/12/08 21:56:27 deraadt Exp $ */ +/* $OpenBSD: init.c,v 1.13 2014/12/31 15:45:57 tedu Exp $ */ /* $NetBSD: init.c,v 1.4 1996/05/21 21:53:05 mrg Exp $ */ /*- @@ -56,6 +56,11 @@ int setbit[16] = {1, 2, 4, 010, 020, 040, 0100, 0200, 0400, 01000, 02000, void init(void) /* everything for 1st time run */ { + /* + * We need deterministic randomness for the obfuscation schemes + * in io.c and setup.c. + */ + srandom_deterministic(1); rdata(); /* read data from orig. file */ linkdata(); poof(); diff --git a/games/adventure/setup.c b/games/adventure/setup.c index 0446a365bee..f062ac368fc 100644 --- a/games/adventure/setup.c +++ b/games/adventure/setup.c @@ -1,4 +1,4 @@ -/* $OpenBSD: setup.c,v 1.11 2014/12/08 21:56:27 deraadt Exp $ */ +/* $OpenBSD: setup.c,v 1.12 2014/12/31 15:45:57 tedu Exp $ */ /* $NetBSD: setup.c,v 1.2 1995/03/21 12:05:10 cgd Exp $ */ /*- @@ -78,6 +78,8 @@ main(int argc, char *argv[]) count = 0; linestart = YES; + srandom_deterministic(1); + while ((c = getc(infile)) != EOF) { if (count++ % LINE == 0) printf("\n\t"); diff --git a/games/adventure/wizard.c b/games/adventure/wizard.c index 5255115834e..ff70f510619 100644 --- a/games/adventure/wizard.c +++ b/games/adventure/wizard.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wizard.c,v 1.16 2014/11/16 04:49:48 guenther Exp $ */ +/* $OpenBSD: wizard.c,v 1.17 2014/12/31 15:45:57 tedu Exp $ */ /* $NetBSD: wizard.c,v 1.3 1995/04/24 12:21:41 cgd Exp $ */ /*- @@ -141,8 +141,5 @@ ciao(void) int ran(int range) { - long i; - - i = random() % range; - return (i); + return (arc4random_uniform(range)); } |