From b4f61842b67867a91cef0f1805c6a60ce11c2303 Mon Sep 17 00:00:00 2001 From: Angus Salkeld Date: Fri, 14 May 2010 02:04:53 +0000 Subject: [PATCH] cov 10381: check result of open() git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2824 fd59a12c-fef9-0310-b244-a6a79926bd2f --- exec/crypto.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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); }