From a0c5530174f91de452d675d5aff30c8bba0c9392 Mon Sep 17 00:00:00 2001 From: fluffymormegil Date: Sun, 10 Oct 2010 21:44:01 +0100 Subject: [PATCH] Minor sanity check in dice_setstate --- src/dice.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/dice.cc b/src/dice.cc index b4b6c31..174d310 100644 --- a/src/dice.cc +++ b/src/dice.cc @@ -58,7 +58,12 @@ extern "C" void dice_setstate(const uint32_t *key, const uint32_t *nonce, const dice_generator.counter = *counter; memcpy(dice_generator.key, key, 8 * sizeof(uint32_t)); memcpy(dice_generator.nonce, nonce, 2 * sizeof(uint32_t)); - dice_generator.subcounter = *subcounter; + dice_generator.subcounter = (*subcounter) & 15; + if (dice_generator.subcounter != 0) + { + /* if the subcounter wasn't zero, the generator will DTwrongT. */ + dice_generator.runstate(); + } } extern "C" void dice_getstate(uint32_t *key, uint32_t *nonce, uint64_t *counter, int *subcounter) -- 2.11.0