aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--random.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/random.c b/random.c
index e96c76a768..d02cd016c0 100644
--- a/random.c
+++ b/random.c
@@ -454,6 +454,7 @@ ruby_fill_random_bytes(void *seed, size_t size, int need_secure)
#define fill_random_bytes ruby_fill_random_bytes
+/* cnt must be 4 or more */
static void
fill_random_seed(uint32_t *seed, size_t cnt)
{
@@ -1466,7 +1467,12 @@ rb_memhash(const void *ptr, long len)
void
Init_RandomSeedCore(void)
{
+ if (!fill_random_bytes(&hash_salt, sizeof(hash_salt), FALSE)) return;
+
/*
+ If failed to fill siphash's salt with random data, expand less random
+ data with MT.
+
Don't reuse this MT for Random::DEFAULT. Random::DEFAULT::seed shouldn't
provide a hint that an attacker guess siphash's seed.
*/