[llvm] r210065 - Process::GetRandomNumber(): fix insecure RNG
Alp Toker
alp at nuanti.com
Mon Jun 2 20:01:04 PDT 2014
Author: alp
Date: Mon Jun 2 22:01:03 2014
New Revision: 210065
URL: http://llvm.org/viewvc/llvm-project?rev=210065&view=rev
Log:
Process::GetRandomNumber(): fix insecure RNG
This could have generated non-random output under error conditions in release
builds.
Modified:
llvm/trunk/lib/Support/Windows/Process.inc
Modified: llvm/trunk/lib/Support/Windows/Process.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Windows/Process.inc?rev=210065&r1=210064&r2=210065&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Windows/Process.inc (original)
+++ llvm/trunk/lib/Support/Windows/Process.inc Mon Jun 2 22:01:03 2014
@@ -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;
}
More information about the llvm-commits
mailing list