diff options
Diffstat (limited to 'src/_cffi_src')
-rw-r--r-- | src/_cffi_src/openssl/src/osrandom_engine.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/_cffi_src/openssl/src/osrandom_engine.c b/src/_cffi_src/openssl/src/osrandom_engine.c index 24dedda4..947c79aa 100644 --- a/src/_cffi_src/openssl/src/osrandom_engine.c +++ b/src/_cffi_src/openssl/src/osrandom_engine.c @@ -92,7 +92,7 @@ static struct { /* return -1 on error */ static int dev_urandom_fd(void) { - int fd, n; + int fd, n, flags; struct stat st; /* Check that fd still points to the correct device */ @@ -106,13 +106,20 @@ static int dev_urandom_fd(void) { } } if (urandom_cache.fd < 0) { - fd = open("/dev/urandom", O_RDONLY | O_CLOEXEC); + fd = open("/dev/urandom", O_RDONLY); if (fd < 0) { goto error; } if (fstat(fd, &st)) { goto error; } + /* set CLOEXEC flag */ + flags = fcntl(fd, F_GETFD); + if (flags == -1) { + goto error; + } else if (fcntl(fd, F_SETFD, flags | FD_CLOEXEC) == -1) { + goto error; + } /* Another thread initialized the fd */ if (urandom_cache.fd >= 0) { do { |