Let's make sure we read it in a way compatible with non-aligned memory.
Fixes: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=812928
if (srand_called)
return;
if (srand_called)
return;
- /* 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);
auxv = (void*) getauxval(AT_RANDOM);
- if (auxv)
- x ^= *(unsigned*) auxv;
+ if (auxv) {
+ assert_cc(sizeof(x) < 16);
+ memcpy(&x, auxv, sizeof(x));
+ } else
x ^= (unsigned) now(CLOCK_REALTIME);
x ^= (unsigned) gettid();
x ^= (unsigned) now(CLOCK_REALTIME);
x ^= (unsigned) gettid();