misc/random: improve the fallback case
c365e2f7 added av_random_bytes() to avoid multiple
threads/processes getting the same seed. but the fallback case
still suffers from it.
also mix in a function pointer, which hopefully is randomized
per process due to ASLR (20+ years old technology) along with
the stack position which will be different on different threads.
This commit is contained in:
1 parent
b3d461e3aa
commit
b968dec77d
1 file changed
+2
@@ -52,6 +52,8 @@ mp_rand_state mp_rand_seed(uint64_t seed)
|
||||
return ret;
|
||||
}
|
||||
seed = mp_raw_time_ns();
|
||||
seed ^= (uintptr_t)&mp_rand_seed; // ASLR, hopefully
|
||||
seed += (uintptr_t)&ret; // stack position
|
||||
}
|
||||
|
||||
ret.v[0] = seed;
|
||||
|
||||
Reference in new issue
Block a user