diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2018-11-07 02:03:09 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-07 02:03:09 +0900 |
commit | 49a060aca840850312bfcc8afecbc84304359bd2 (patch) | |
tree | 206e43e6c61a49e76590846832e3ccdd46e5d880 | |
parent | 6260d28b8a002a401eab7511f96fd62f471dccdb (diff) | |
parent | 92025e8f521c55c9360ea749d139d796f62efb96 (diff) | |
download | systemd-49a060aca840850312bfcc8afecbc84304359bd2.tar.gz systemd-49a060aca840850312bfcc8afecbc84304359bd2.tar.bz2 systemd-49a060aca840850312bfcc8afecbc84304359bd2.zip |
Merge pull request #10654 from poettering/srand-rdrand
random-util.c mini-fixes
-rw-r--r-- | src/basic/random-util.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/basic/random-util.c b/src/basic/random-util.c index aa04cc2318..071a41f186 100644 --- a/src/basic/random-util.c +++ b/src/basic/random-util.c @@ -142,8 +142,9 @@ void initialize_srand(void) { static bool srand_called = false; unsigned x; #if HAVE_SYS_AUXV_H - void *auxv; + const void *auxv; #endif + uint64_t k; if (srand_called) return; @@ -153,7 +154,7 @@ void initialize_srand(void) { * try to make use of that to seed the pseudo-random generator. It's * better than nothing... */ - auxv = (void*) getauxval(AT_RANDOM); + auxv = (const void*) getauxval(AT_RANDOM); if (auxv) { assert_cc(sizeof(x) <= 16); memcpy(&x, auxv, sizeof(x)); @@ -164,6 +165,9 @@ void initialize_srand(void) { x ^= (unsigned) now(CLOCK_REALTIME); x ^= (unsigned) gettid(); + if (rdrand64(&k) >= 0) + x ^= (unsigned) k; + srand(x); srand_called = true; } |