libc: Ensure /dev/random is opened with O_CLOEXEC on init

This commit is contained in:
apio 2022-10-27 17:50:15 +02:00
parent d93a4062a2
commit 8ed0ff1381

View File

@ -15,7 +15,8 @@ static void initialize_random()
{
unsigned int seed = 3735928559U;
FILE* fp = fopen("/dev/random", "rw");
int fd = open("/dev/random", O_RDONLY | O_CLOEXEC); // If we somehow fail to close this file, close it on exec.
FILE* fp = fdopen(fd, "r");
if (!fp)
{
errno = 0;