diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2014-01-18 01:58:34 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2014-01-18 01:58:34 +0000 |
commit | 67dbfe796436d3f002708ec00bb0e56d593f2f18 (patch) | |
tree | afd2c8ccc560b0777718c2899738c42940a2c9e6 /sys/ddb/db_hangman.c | |
parent | 650548146a619aa2c1d7f3e2e70ce67db7fa614f (diff) |
Use arc4random_uniform to increase the slightly difficulty of winning.
Kidding, the fix is to stop using the scheduler's PRNG.
ok kettenis
Diffstat (limited to 'sys/ddb/db_hangman.c')
-rw-r--r-- | sys/ddb/db_hangman.c | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/sys/ddb/db_hangman.c b/sys/ddb/db_hangman.c index 54b33777336..b3bbe4739f0 100644 --- a/sys/ddb/db_hangman.c +++ b/sys/ddb/db_hangman.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_hangman.c,v 1.28 2008/04/18 06:42:20 djm Exp $ */ +/* $OpenBSD: db_hangman.c,v 1.29 2014/01/18 01:58:33 deraadt Exp $ */ /* * Copyright (c) 1996 Theo de Raadt, Michael Shalayeff @@ -67,14 +67,6 @@ static const char hangpic[]= "9 "; static const char substchar[]="\\/|\\/O|/-|"; -static size_t -db_random(size_t mod) -{ - if (cold) - return (random() % mod); - return (arc4random_uniform(mod)); -} - struct db_hang_forall_arg { int cnt; db_sym_t sym; @@ -111,7 +103,7 @@ db_randomsym(size_t *lenp) if (nsymtabs == 0) return (NULL); - stab = &db_symtabs[db_random(nsymtabs)]; + stab = &db_symtabs[arc4random_uniform(nsymtabs)]; dfa.cnt = 0; X_db_forall(stab, db_hang_forall, &dfa); @@ -120,7 +112,7 @@ db_randomsym(size_t *lenp) if (nsyms == 0) return (NULL); - dfa.cnt = db_random(nsyms); + dfa.cnt = arc4random_uniform(nsyms); X_db_forall(stab, db_hang_forall, &dfa); q = db_qualify(dfa.sym, stab->name); |