Prevent tampering with PRNG parameters in save
authorNHOrus <jy6x2b32pie9@yahoo.com>
Thu, 24 Aug 2017 11:48:02 +0000 (14:48 +0300)
committerNHOrus <jy6x2b32pie9@yahoo.com>
Thu, 24 Aug 2017 11:48:02 +0000 (14:48 +0300)
main.c
saveresume.c

diff --git a/main.c b/main.c
index 0f245a2d0e6d971279ebaab0e7b6157f7a39106d..0556c01f9da86fa92824bfa31fcf2400f3b39b3d 100644 (file)
--- a/main.c
+++ b/main.c
@@ -1175,9 +1175,6 @@ Lookup:
         default: // LCOV_EXCL_LINE
             BUG(VOCABULARY_TYPE_N_OVER_1000_NOT_BETWEEN_0_AND_3); // LCOV_EXCL_LINE
         }
-        if (!is_valid(game)) {
-            exit(1);
-        }
         switch (action(command)) {
         case GO_TERMINATE:
             return true;
index cf1dd6c287115f7790fe92f0ac25a0542cd5dcee..c5d51816e3b664029fbf09c6eed7872811663798 100644 (file)
@@ -139,6 +139,12 @@ bool is_valid(struct game_t valgame)
         return false;
     }
 
+    /* Prevent RNG substitution. Why we are saving PRNG parameters? */
+
+    if (valgame.lcg_a != game.lcg_a || valgame.lcg_c != game.lcg_c || valgame.lcg_m != game.lcg_m) {
+        return false;
+    }
+
     /*  Bounds check for locations */
     if ( valgame.chloc < -1  || valgame.chloc > NLOCATIONS  ||
          valgame.chloc2 < -1  || valgame.chloc2 > NLOCATIONS  ||