diff options
author | B Stack <bgstack15@gmail.com> | 2019-02-10 16:47:23 -0500 |
---|---|---|
committer | B Stack <bgstack15@gmail.com> | 2019-02-10 16:47:23 -0500 |
commit | a48439992d4b1c896dd0beaff91d0a14361032b9 (patch) | |
tree | 475a67b0b138f2b1cd5f02eaab8e413f7eee62c6 /zen/guid.h | |
parent | Merge branch '10.8' into 'master' (diff) | |
download | FreeFileSync-a48439992d4b1c896dd0beaff91d0a14361032b9.tar.gz FreeFileSync-a48439992d4b1c896dd0beaff91d0a14361032b9.tar.bz2 FreeFileSync-a48439992d4b1c896dd0beaff91d0a14361032b9.zip |
10.9
Diffstat (limited to 'zen/guid.h')
-rw-r--r--[-rwxr-xr-x] | zen/guid.h | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/zen/guid.h b/zen/guid.h index a26688f8..c89e8082 100755..100644 --- 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<std::string>(__LINE__) + "] Failed to generate GUID." + "\n" + utfTo<std::string>(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; } } |