summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlp Toker <alp@nuanti.com>2014-06-03 03:01:03 +0000
committerAlp Toker <alp@nuanti.com>2014-06-03 03:01:03 +0000
commit1860902c452ae234e45a013a116c6265ef36643e (patch)
tree25d3188d504a1f48b1af5a429fe1a4ff82269388
parent2d21b25393a461fbf8ab824889a6c56e1dd0b1cb (diff)
downloadllvm-1860902c452ae234e45a013a116c6265ef36643e.tar.gz
llvm-1860902c452ae234e45a013a116c6265ef36643e.tar.bz2
llvm-1860902c452ae234e45a013a116c6265ef36643e.tar.xz
Process::GetRandomNumber(): fix insecure RNG
This could have generated non-random output under error conditions in release builds. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210065 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Support/Windows/Process.inc5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/Support/Windows/Process.inc b/lib/Support/Windows/Process.inc
index 5e3fd7ecdc..006bd80084 100644
--- a/lib/Support/Windows/Process.inc
+++ b/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;
}