From 1cc65eec8897aec3f6abe8a28f3c4b18008d26ee Mon Sep 17 00:00:00 2001 From: tedu Date: Wed, 31 Dec 2014 15:45:57 +0000 Subject: [PATCH] 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 --- games/adventure/init.c | 7 ++++++- games/adventure/setup.c | 4 +++- 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)); } -- 2.20.1