misc/random: set constant seed for fuzzing

Fuzzing expect deterministic behavior. While we don't use this random
generator for anything significant, still good to set the seed, in case
of future usage.
This commit is contained in:
Kacper Michajłow 2024-06-23 16:45:51 +02:00
parent 799137a87c
commit a949e0c2d5
1 changed files with 3 additions and 0 deletions

View File

@ -41,6 +41,9 @@ static inline uint64_t splitmix64(uint64_t *const x)
void mp_rand_seed(uint64_t seed)
{
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
seed = 42;
#endif
mp_mutex_lock(&state_mutex);
state[0] = seed;
for (int i = 1; i < 4; i++)