From b13a74b35b17ecb44ec6ff552ecb1cbdac204361 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 18 Feb 2016 09:57:35 -0500 Subject: [PATCH 1/2] cmSystemTools: Remove unused include We do not seem to need this header anymore, and including it on AIX causes `#define open open64` which breaks `std::ifstream::open` calls. --- Source/cmSystemTools.cxx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 3ba72876c3..c9670faf08 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -60,8 +60,7 @@ #endif #if defined(CMAKE_BUILD_WITH_CMAKE) -# include -# include "cmCryptoHash.h" +# include "cmCryptoHash.h" #endif #if defined(CMAKE_USE_ELF_PARSER) From f23f18ab686faa0ce91486143469bb58753b0843 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristian=20Rodr=C3=ADguez?= Date: Wed, 17 Feb 2016 09:02:04 -0500 Subject: [PATCH 2/2] cmSystemTools: Avoid excess entropy consumption by RandomSeed (#15976) Read `/dev/urandom` without buffering to avoid taking more than we need. --- Source/cmSystemTools.cxx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index c9670faf08..9af54bffca 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -2183,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;