diff options
author | Brad King <brad.king@kitware.com> | 2016-02-19 14:47:41 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2016-02-19 14:47:41 (GMT) |
commit | 39a80a1febde53de8747d2062cf23cf4dad4584a (patch) | |
tree | 3d62a656cab310b15a60f492094fbc853fe09af7 /Source | |
parent | c387325d4adb69e411f0832e6e3949ba2a4a7f79 (diff) | |
parent | f23f18ab686faa0ce91486143469bb58753b0843 (diff) | |
download | CMake-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.cxx | 9 |
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; |