summaryrefslogtreecommitdiff
path: root/src/basic/random-util.c
diff options
context:
space:
mode:
authorDaniel Mack <github@zonque.org>2016-01-28 17:37:06 +0100
committerDaniel Mack <github@zonque.org>2016-01-28 17:37:06 +0100
commit9e83569d8ff219730912ecac441843b9531b079c (patch)
tree12dbaa356557f24bbe08458e8391610a52932dc1 /src/basic/random-util.c
parentcd72d2044ad28b475bf84a38ba6db45292467dd8 (diff)
parentad6b1fa287c1d007fd85aa3e85b7e4a6bc7f515f (diff)
Merge pull request #2463 from poettering/machined-tty-fix
Fixes for the service TTY reset logic and other stuff
Diffstat (limited to 'src/basic/random-util.c')
-rw-r--r--src/basic/random-util.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/basic/random-util.c b/src/basic/random-util.c
index e1543da5a3..2f468db770 100644
--- a/src/basic/random-util.c
+++ b/src/basic/random-util.c
@@ -95,17 +95,18 @@ void initialize_srand(void) {
if (srand_called)
return;
- x = 0;
-
#ifdef HAVE_SYS_AUXV_H
- /* The kernel provides us with a bit of entropy in auxv, so
- * let's try to make use of that to seed the pseudo-random
- * generator. It's better than nothing... */
+ /* The kernel provides us with 16 bytes of entropy in auxv, so let's try to make use of that to seed the
+ * pseudo-random generator. It's better than nothing... */
auxv = (void*) getauxval(AT_RANDOM);
- if (auxv)
- x ^= *(unsigned*) auxv;
+ if (auxv) {
+ assert_cc(sizeof(x) < 16);
+ memcpy(&x, auxv, sizeof(x));
+ } else
#endif
+ x = 0;
+
x ^= (unsigned) now(CLOCK_REALTIME);
x ^= (unsigned) gettid();