diff options
author | Alp Toker <alp@nuanti.com> | 2014-06-03 03:01:03 +0000 |
---|---|---|
committer | Alp Toker <alp@nuanti.com> | 2014-06-03 03:01:03 +0000 |
commit | 552f2f7b96f8fe7aa67d675b90ddde095ec5629a (patch) | |
tree | cb1c25f2a720557efbf6c50a32a8e43bd4385003 /llvm/lib/Support/Windows/Process.inc | |
parent | b8f8099895220df694e9cdebea24c6f9ca7e63e7 (diff) | |
download | llvm-552f2f7b96f8fe7aa67d675b90ddde095ec5629a.zip llvm-552f2f7b96f8fe7aa67d675b90ddde095ec5629a.tar.gz llvm-552f2f7b96f8fe7aa67d675b90ddde095ec5629a.tar.bz2 |
Process::GetRandomNumber(): fix insecure RNG
This could have generated non-random output under error conditions in release
builds.
llvm-svn: 210065
Diffstat (limited to 'llvm/lib/Support/Windows/Process.inc')
-rw-r--r-- | llvm/lib/Support/Windows/Process.inc | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/llvm/lib/Support/Windows/Process.inc b/llvm/lib/Support/Windows/Process.inc index 5e3fd7e..006bd80 100644 --- a/llvm/lib/Support/Windows/Process.inc +++ b/llvm/lib/Support/Windows/Process.inc @@ -12,6 +12,7 @@ //===----------------------------------------------------------------------===// #include "llvm/Support/Allocator.h" +#include "llvm/Support/ErrorHandling.h" #include <malloc.h> // The Windows.h header must be after LLVM and standard headers. @@ -363,12 +364,12 @@ unsigned Process::GetRandomNumber() { HCRYPTPROV HCPC; if (!::CryptAcquireContextW(&HCPC, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) - assert(false && "Could not acquire a cryptographic context"); + report_fatal_error("Could not acquire a cryptographic context"); ScopedCryptContext CryptoProvider(HCPC); unsigned Ret; if (!::CryptGenRandom(CryptoProvider, sizeof(Ret), reinterpret_cast<BYTE *>(&Ret))) - assert(false && "Could not generate a random number"); + report_fatal_error("Could not generate a random number"); return Ret; } |