Commit 75e1242d authored by Wez Furlong's avatar Wez Furlong Committed by Facebook Github Bot

enable O_CLOEXEC for /dev/urandom

Summary: There's no need for this to be inheritable

Reviewed By: yfeldblum

Differential Revision: D10139559

fbshipit-source-id: ae2db0d13e33c383fd73c0563b127e62e54a7094
parent b7e06ff9
...@@ -63,7 +63,7 @@ void readRandomDevice(void* data, size_t size) { ...@@ -63,7 +63,7 @@ void readRandomDevice(void* data, size_t size) {
PCHECK(CryptGenRandom(cryptoProv, (DWORD)size, (BYTE*)data)); PCHECK(CryptGenRandom(cryptoProv, (DWORD)size, (BYTE*)data));
#else #else
// Keep the random device open for the duration of the program. // Keep the random device open for the duration of the program.
static int randomFd = ::open("/dev/urandom", O_RDONLY); static int randomFd = ::open("/dev/urandom", O_RDONLY | O_CLOEXEC);
PCHECK(randomFd >= 0); PCHECK(randomFd >= 0);
auto bytesRead = readFull(randomFd, data, size); auto bytesRead = readFull(randomFd, data, size);
PCHECK(bytesRead >= 0 && size_t(bytesRead) == size); PCHECK(bytesRead >= 0 && size_t(bytesRead) == size);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment