summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2016-02-19 14:47:41 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2016-02-19 14:47:41 (GMT)
commit39a80a1febde53de8747d2062cf23cf4dad4584a (patch)
tree3d62a656cab310b15a60f492094fbc853fe09af7 /Source
parentc387325d4adb69e411f0832e6e3949ba2a4a7f79 (diff)
parentf23f18ab686faa0ce91486143469bb58753b0843 (diff)
downloadCMake-39a80a1febde53de8747d2062cf23cf4dad4584a.zip
CMake-39a80a1febde53de8747d2062cf23cf4dad4584a.tar.gz
CMake-39a80a1febde53de8747d2062cf23cf4dad4584a.tar.bz2
Merge topic 'reduce-entropy-consumption'
f23f18ab cmSystemTools: Avoid excess entropy consumption by RandomSeed (#15976) b13a74b3 cmSystemTools: Remove unused include <fcntl.h>
Diffstat (limited to 'Source')
-rw-r--r--Source/cmSystemTools.cxx9
1 files changed, 5 insertions, 4 deletions
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 3ba7287..9af54bf 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -60,8 +60,7 @@
#endif
#if defined(CMAKE_BUILD_WITH_CMAKE)
-# include <fcntl.h>
-# include "cmCryptoHash.h"
+# include "cmCryptoHash.h"
#endif
#if defined(CMAKE_USE_ELF_PARSER)
@@ -2184,8 +2183,10 @@ unsigned int cmSystemTools::RandomSeed()
} seed;
// Try using a real random source.
- cmsys::ifstream fin("/dev/urandom");
- if(fin && fin.read(seed.bytes, sizeof(seed)) &&
+ cmsys::ifstream fin;
+ fin.rdbuf()->pubsetbuf(0, 0); // Unbuffered read.
+ fin.open("/dev/urandom");
+ if(fin.good() && fin.read(seed.bytes, sizeof(seed)) &&
fin.gcount() == sizeof(seed))
{
return seed.integer;