Merge topic 'reduce-entropy-consumption'
f23f18ab
cmSystemTools: Avoid excess entropy consumption by RandomSeed (#15976)b13a74b3
cmSystemTools: Remove unused include <fcntl.h>
This commit is contained in:
commit
39a80a1feb
|
@ -60,8 +60,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(CMAKE_BUILD_WITH_CMAKE)
|
#if defined(CMAKE_BUILD_WITH_CMAKE)
|
||||||
# include <fcntl.h>
|
# include "cmCryptoHash.h"
|
||||||
# include "cmCryptoHash.h"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(CMAKE_USE_ELF_PARSER)
|
#if defined(CMAKE_USE_ELF_PARSER)
|
||||||
|
@ -2184,8 +2183,10 @@ unsigned int cmSystemTools::RandomSeed()
|
||||||
} seed;
|
} seed;
|
||||||
|
|
||||||
// Try using a real random source.
|
// Try using a real random source.
|
||||||
cmsys::ifstream fin("/dev/urandom");
|
cmsys::ifstream fin;
|
||||||
if(fin && fin.read(seed.bytes, sizeof(seed)) &&
|
fin.rdbuf()->pubsetbuf(0, 0); // Unbuffered read.
|
||||||
|
fin.open("/dev/urandom");
|
||||||
|
if(fin.good() && fin.read(seed.bytes, sizeof(seed)) &&
|
||||||
fin.gcount() == sizeof(seed))
|
fin.gcount() == sizeof(seed))
|
||||||
{
|
{
|
||||||
return seed.integer;
|
return seed.integer;
|
||||||
|
|
Loading…
Reference in New Issue