From a48439992d4b1c896dd0beaff91d0a14361032b9 Mon Sep 17 00:00:00 2001 From: B Stack Date: Sun, 10 Feb 2019 16:47:23 -0500 Subject: 10.9 --- zen/guid.h | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) mode change 100755 => 100644 zen/guid.h (limited to 'zen/guid.h') diff --git a/zen/guid.h b/zen/guid.h old mode 100755 new mode 100644 index a26688f8..c89e8082 --- a/zen/guid.h +++ b/zen/guid.h @@ -18,13 +18,11 @@ namespace zen inline std::string generateGUID() //creates a 16-byte GUID { -#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 25) //getentropy() requires glibc 2.25 (ldd --version) PS: Centos 7 is on 2.17 std::string guid(16, '\0'); - if (::getentropy(&guid[0], 16) != 0) //"The maximum permitted value for the length argument is 256" +#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 25) //getentropy() requires glibc 2.25 (ldd --version) PS: CentOS 7 is on 2.17 + if (::getentropy(&guid[0], guid.size()) != 0) //"The maximum permitted value for the length argument is 256" throw std::runtime_error(std::string(__FILE__) + "[" + numberTo(__LINE__) + "] Failed to generate GUID." + "\n" + utfTo(formatSystemError(L"getentropy", errno))); - return guid; - #else class RandomGeneratorPosix { @@ -55,10 +53,9 @@ std::string generateGUID() //creates a 16-byte GUID const int fd_ = ::open("/dev/urandom", O_RDONLY | O_CLOEXEC); }; thread_local RandomGeneratorPosix gen; - std::string guid(16, '\0'); - gen.getBytes(&guid[0], 16); - return guid; + gen.getBytes(&guid[0], guid.size()); #endif + return guid; } } -- cgit