Fix possible unaligned ptr from getauxval

This caused SIGILL on armv7a-linux
This commit is contained in:
Timon Kruiper 2020-03-31 20:15:09 +02:00 committed by Andrew Kelley
parent c7a3796734
commit 9e019ed26b

View File

@ -1456,7 +1456,10 @@ static void init_rand() {
memcpy(&seed, bytes, sizeof(unsigned));
srand(seed);
#elif defined(ZIG_OS_LINUX)
srand(*((unsigned*)getauxval(AT_RANDOM)));
unsigned char *ptr_random = (unsigned char*)getauxval(AT_RANDOM);
unsigned seed;
memcpy(&seed, ptr_random, sizeof(seed));
srand(seed);
#else
int fd = open("/dev/urandom", O_RDONLY|O_CLOEXEC);
if (fd == -1) {