diff options
author | Daniel Wilhelm <shieldwed@outlook.com> | 2019-02-13 21:05:15 +0000 |
---|---|---|
committer | Daniel Wilhelm <shieldwed@outlook.com> | 2019-02-13 21:05:15 +0000 |
commit | 2e618740c10a6dc7f5a8ee031a196b4ac95b1294 (patch) | |
tree | 475a67b0b138f2b1cd5f02eaab8e413f7eee62c6 /zen/guid.h | |
parent | Merge branch '10.8' into 'master' (diff) | |
parent | 10.9 (diff) | |
download | FreeFileSync-2e618740c10a6dc7f5a8ee031a196b4ac95b1294.tar.gz FreeFileSync-2e618740c10a6dc7f5a8ee031a196b4ac95b1294.tar.bz2 FreeFileSync-2e618740c10a6dc7f5a8ee031a196b4ac95b1294.zip |
Merge branch '10.9' into 'master'10.9
10.9
See merge request opensource-tracking/FreeFileSync!6
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; } } |