diff options
author | 2014-11-03 19:18:16 +0000 | |
---|---|---|
committer | 2014-11-03 19:18:16 +0000 | |
commit | a8ed32d4ad23ba91a3000c5beb9a6862ee2d3be0 (patch) | |
tree | f2dab0b89cd7697ee009c81d10805c90638ae2af | |
parent | Convert the logic in yyerror(). Instead of creating a temporary (diff) | |
download | wireguard-openbsd-a8ed32d4ad23ba91a3000c5beb9a6862ee2d3be0.tar.xz wireguard-openbsd-a8ed32d4ad23ba91a3000c5beb9a6862ee2d3be0.zip |
the man page says it is impossible to cheat, but since the shuffle is
lopsided, a sharp counter can detect uneven permutations. fix this by
using knuth shuffle.
ok mlarkin pjanzen
-rw-r--r-- | games/canfield/canfield/canfield.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/games/canfield/canfield/canfield.c b/games/canfield/canfield/canfield.c index 3b139dcd99c..b45bbf0ffd9 100644 --- a/games/canfield/canfield/canfield.c +++ b/games/canfield/canfield/canfield.c @@ -1,4 +1,4 @@ -/* $OpenBSD: canfield.c,v 1.13 2013/08/29 20:22:11 naddy Exp $ */ +/* $OpenBSD: canfield.c,v 1.14 2014/11/03 19:18:16 tedu Exp $ */ /* $NetBSD: canfield.c,v 1.7 1995/05/13 07:28:35 jtc Exp $ */ /* @@ -533,8 +533,8 @@ shuffle(struct cardtype *deck[]) deck[i]->visible = FALSE; deck[i]->paid = FALSE; } - for (i = decksize-1; i>=0; i--) { - j = arc4random_uniform(decksize); + for (i = decksize - 1; i > 0; i--) { + j = arc4random_uniform(i + 1); if (i != j) { temp = deck[i]; deck[i] = deck[j]; |