mirror of
https://github.com/ziglang/zig.git
synced 2025-12-25 15:43:06 +00:00
Fix possible unaligned ptr from getauxval
This caused SIGILL on armv7a-linux
This commit is contained in:
parent
c7a3796734
commit
9e019ed26b
@ -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) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user