diff --git a/exec/crypto.c b/exec/crypto.c index 0ae415e8..f85f4b92 100644 --- a/exec/crypto.c +++ b/exec/crypto.c @@ -1258,9 +1258,10 @@ static unsigned long rng_nix(unsigned char *buf, unsigned long len, fd = open ("/dev/urandom", O_RDONLY); - rb = (unsigned long)read (fd, buf, len); - - close (fd); + if (fd >= 0) { + rb = (unsigned long)read (fd, buf, len); + close (fd); + } return (rb); }