From f84032eda8c5fcbbef8d34a5cf6dceebc46aac45 Mon Sep 17 00:00:00 2001 From: deraadt Date: Mon, 8 Dec 2014 21:56:27 +0000 Subject: [PATCH] For now, these games still contain deterministic randomization (for save / replay modes of operation that have not yet been cleaned up). OK, I've let the cat out of the bag, now some of you know you can cheat at them.. ok millert guenther tedu --- games/adventure/hdr.h | 4 +--- games/adventure/init.c | 3 +-- games/adventure/io.c | 3 +-- games/adventure/save.c | 6 +++--- games/adventure/setup.c | 4 +--- games/atc/update.c | 4 ++-- games/hack/hack.main.c | 5 ++--- games/trek/main.c | 3 +-- games/trek/setup.c | 4 ++-- 9 files changed, 14 insertions(+), 22 deletions(-) diff --git a/games/adventure/hdr.h b/games/adventure/hdr.h index bb5c72c50eb..4c286b45df2 100644 --- a/games/adventure/hdr.h +++ b/games/adventure/hdr.h @@ -1,4 +1,4 @@ -/* $OpenBSD: hdr.h,v 1.13 2014/07/13 19:40:57 tedu Exp $ */ +/* $OpenBSD: hdr.h,v 1.14 2014/12/08 21:56:27 deraadt Exp $ */ /* $NetBSD: hdr.h,v 1.2 1995/03/21 12:05:02 cgd Exp $ */ /*- @@ -83,8 +83,6 @@ struct hashtab { /* hash table for vocabulary */ char *atab; /* pointer to actual string */ } voc[HTSIZE]; -#define SEED 1815622 /* "obfuscation" seed */ - struct text { #ifdef OLDSTUFF int seekadr; /* DATFILE must be < 2**16 */ diff --git a/games/adventure/init.c b/games/adventure/init.c index 9c60994258c..6de5b774b9d 100644 --- a/games/adventure/init.c +++ b/games/adventure/init.c @@ -1,4 +1,4 @@ -/* $OpenBSD: init.c,v 1.11 2009/10/27 23:59:23 deraadt Exp $ */ +/* $OpenBSD: init.c,v 1.12 2014/12/08 21:56:27 deraadt Exp $ */ /* $NetBSD: init.c,v 1.4 1996/05/21 21:53:05 mrg Exp $ */ /*- @@ -213,7 +213,6 @@ void startup(void) { demo = Start(); - srandomdev(); hinted[3] = yes(65, 1, 0); newloc = 1; delhit = 0; diff --git a/games/adventure/io.c b/games/adventure/io.c index bcf49254567..4c02ccb096e 100644 --- a/games/adventure/io.c +++ b/games/adventure/io.c @@ -1,4 +1,4 @@ -/* $OpenBSD: io.c,v 1.18 2014/07/13 19:40:57 tedu Exp $ */ +/* $OpenBSD: io.c,v 1.19 2014/12/08 21:56:27 deraadt Exp $ */ /* $NetBSD: io.c,v 1.3 1995/04/24 12:21:37 cgd Exp $ */ /*- @@ -201,7 +201,6 @@ rdata(void) /* "read" data from virtual file */ char ch; inptr = data_file; /* Pointer to virtual data file */ - srandom(SEED); /* which is slightly obfuscated.*/ clsses = 1; for (;;) { /* read data sections */ diff --git a/games/adventure/save.c b/games/adventure/save.c index 483dd8a309b..2b0fe806234 100644 --- a/games/adventure/save.c +++ b/games/adventure/save.c @@ -1,4 +1,4 @@ -/* $OpenBSD: save.c,v 1.9 2014/07/13 19:40:57 tedu Exp $ */ +/* $OpenBSD: save.c,v 1.10 2014/12/08 21:56:27 deraadt Exp $ */ /* $NetBSD: save.c,v 1.2 1995/03/21 12:05:08 cgd Exp $ */ /*- @@ -127,7 +127,7 @@ save(const char *outfile) crc_start(); for (p = save_array; p->address != NULL; p++) sum = crc(p->address, p->width); - srandom((int) sum); + srandom_deterministic((int) sum); if ((out = fopen(outfile, "wb")) == NULL) { fprintf(stderr, @@ -163,7 +163,7 @@ restore(const char *infile) } fread(&sum, sizeof(sum), 1, in); /* Get the seed */ - srandom((unsigned int) sum); + srandom_deterministic((unsigned int) sum); for (p = save_array; p->address != NULL; p++) { fread(p->address, p->width, 1, in); for (s = p->address, i = 0; i < p->width; i++, s++) diff --git a/games/adventure/setup.c b/games/adventure/setup.c index 9db2d1c5a90..0446a365bee 100644 --- a/games/adventure/setup.c +++ b/games/adventure/setup.c @@ -1,4 +1,4 @@ -/* $OpenBSD: setup.c,v 1.10 2014/07/13 19:40:57 tedu Exp $ */ +/* $OpenBSD: setup.c,v 1.11 2014/12/08 21:56:27 deraadt Exp $ */ /* $NetBSD: setup.c,v 1.2 1995/03/21 12:05:10 cgd Exp $ */ /*- @@ -49,7 +49,6 @@ #include #include #include -#include "hdr.h" /* SEED lives in there; keep them coordinated. */ #define USAGE "Usage: setup file > data.c (file is typically glorkz)\n" @@ -76,7 +75,6 @@ main(int argc, char *argv[]) puts(SIG2); puts(" */"); printf("\n\nchar data_file[] =\n{"); - srandom(SEED); count = 0; linestart = YES; diff --git a/games/atc/update.c b/games/atc/update.c index f6d09de48e6..86536a23e79 100644 --- a/games/atc/update.c +++ b/games/atc/update.c @@ -1,4 +1,4 @@ -/* $OpenBSD: update.c,v 1.14 2014/07/13 14:01:04 tedu Exp $ */ +/* $OpenBSD: update.c,v 1.15 2014/12/08 21:56:27 deraadt Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -48,7 +48,7 @@ void setseed(const char *seed) { seeded = 1; - srandom(atol(seed)); + srandom_deterministic(atol(seed)); } uint32_t diff --git a/games/hack/hack.main.c b/games/hack/hack.main.c index 6c28c8738e5..045d4e9cc61 100644 --- a/games/hack/hack.main.c +++ b/games/hack/hack.main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hack.main.c,v 1.15 2009/10/27 23:59:25 deraadt Exp $ */ +/* $OpenBSD: hack.main.c,v 1.16 2014/12/08 21:56:27 deraadt Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, @@ -177,7 +177,6 @@ main(int argc, char **argv) gettty(); setbuf(stdout,obuf); umask(007); - srandomdev(); startup(); cls(); u.uhp = 1; /* prevent RIP on early quits */ @@ -275,7 +274,7 @@ main(int argc, char **argv) if ((sfoo = getenv("MAGIC"))) while(*sfoo) { switch(*sfoo++) { - case 'n': (void) srandom(*sfoo++); + case 'n': (void) srandom_deterministic(*sfoo++); break; } } diff --git a/games/trek/main.c b/games/trek/main.c index b89df78ec41..cc3617c65ec 100644 --- a/games/trek/main.c +++ b/games/trek/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.12 2009/10/27 23:59:27 deraadt Exp $ */ +/* $OpenBSD: main.c,v 1.13 2014/12/08 21:56:28 deraadt Exp $ */ /* $NetBSD: main.c,v 1.4 1995/04/22 10:59:10 cgd Exp $ */ /* @@ -127,7 +127,6 @@ main(argc, argv) av = argv; ac = argc; av++; - srandomdev(); #ifdef xTRACE Trace = 0; diff --git a/games/trek/setup.c b/games/trek/setup.c index 8c0b4afca57..217a15192e2 100644 --- a/games/trek/setup.c +++ b/games/trek/setup.c @@ -1,4 +1,4 @@ -/* $OpenBSD: setup.c,v 1.9 2013/08/29 14:35:49 naddy Exp $ */ +/* $OpenBSD: setup.c,v 1.10 2014/12/08 21:56:28 deraadt Exp $ */ /* $NetBSD: setup.c,v 1.4 1995/04/24 12:26:06 cgd Exp $ */ /* @@ -105,7 +105,7 @@ setup() d = 0; for (i = 0; Game.passwd[i]; i++) d += Game.passwd[i] << i; - srandom(d); + srandom_deterministic(d); } Param.bases = Now.bases = ranf(6 - Game.skill) + 2; if (Game.skill == 6)