From: Jarkko Hietaniemi Date: Sat, 5 Jul 2003 10:56:55 +0000 (+0000) Subject: The logic for additional randomisation for 64-bit UV X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=822df56176318d6ed90d76ef3dcd74f3721e140b;p=p5sagit%2Fp5-mst-13.2.git The logic for additional randomisation for 64-bit UV cases was wrong. p4raw-id: //depot/perl@20009 --- diff --git a/perl.c b/perl.c index c7a8282..bf707c0 100644 --- a/perl.c +++ b/perl.c @@ -917,12 +917,12 @@ setuid perl scripts securely.\n"); PL_srand_called = TRUE; PL_hash_seed = (UV)(Drand01() * (NV)UV_MAX); #if RANDBITS < (UVSIZE * 8) - { - int skip = (UVSIZE * 8) - RANDBITS; - PL_hash_seed >>= skip; - /* The low bits might need extra help. */ - PL_hash_seed += (UV)(Drand01() * ((1 << skip) - 1)); - } + /* Since there are not enough randbits to to reach all + * the bits of a UV, the low bits might need extra + * help. Sum in another random number that will + * fill in the low bits. */ + PL_hash_seed += + (UV)(Drand01() * (NV)((1 << ((UVSIZE * 8 - RANDBITS))) - 1)); #endif /* RANDBITS < (UVSIZE * 8) */ } #endif /* USE_HASH_SEED_EXPLICIT */