Files
libfaketime/test/librandom.c
Daniel Kahn Gillmor 8f2c856d8e test getrandom() in library initialization without FAKERANDOM_SEED
Running "make randomtest" should demonstrates the segfault described
in https://github.com/wolfcw/libfaketime/issues/295
2021-02-23 11:14:37 -05:00

18 lines
401 B
C

#include <stdio.h>
#include <sys/random.h>
void func() {
fprintf(stderr, " called func()\n");
}
static __attribute__((constructor)) void rnd_init() {
unsigned int targ;
ssize_t ret = getrandom(&targ, sizeof(targ), 0);
if (ret == sizeof(targ)) {
fprintf(stderr, " getrandom() yielded 0x%08x\n", targ);
} else {
fprintf(stderr, " getrandom() failed with only %zd\n", ret);
}
}