core: Use /dev/urandom for getrandom fallback

Sami Farin pointed out on #833 that on Linux kernels older than 5.6,
/dev/random blocks when entropy estimates are too low, whereas
/dev/urandom does not.

Signed-off-by: Simon McVittie <smcv@collabora.com>
This commit is contained in:
Simon McVittie 2021-10-27 13:25:30 +01:00 committed by Wim Taymans
parent 3509962f3a
commit f6b1d65e35

View file

@ -38,7 +38,7 @@
#include <fcntl.h>
ssize_t getrandom(void *buf, size_t buflen, unsigned int flags) {
int fd = open("/dev/random", O_CLOEXEC);
int fd = open("/dev/urandom", O_CLOEXEC);
if (fd < 0)
return -1;
ssize_t bytes = read(fd, buf, buflen);