[PATCH] D14583: Report Windows error code in a fatal error after a system call
Paul Robinson via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 11 12:28:51 PST 2015
probinson created this revision.
probinson added a reviewer: aaron.ballman.
probinson added a subscriber: cfe-commits.
We've had two reports in the past year that CryptAcquireContextW failed; but without the Windows error code it's hard to know what's going on.
http://reviews.llvm.org/D14583
Files:
lib/Support/Windows/Process.inc
Index: lib/Support/Windows/Process.inc
===================================================================
--- lib/Support/Windows/Process.inc
+++ lib/Support/Windows/Process.inc
@@ -417,16 +417,23 @@
return 0;
}
+// Include GetLastError() in a fatal error message.
+static void ReportLastErrorFatal(const char *msg) {
+ std::string ErrMsg;
+ MakeErrMsg(&ErrMsg, msg);
+ report_fatal_error(ErrMsg);
+}
+
unsigned Process::GetRandomNumber() {
HCRYPTPROV HCPC;
if (!::CryptAcquireContextW(&HCPC, NULL, NULL, PROV_RSA_FULL,
CRYPT_VERIFYCONTEXT))
- report_fatal_error("Could not acquire a cryptographic context");
+ ReportLastErrorFatal("Could not acquire a cryptographic context");
ScopedCryptContext CryptoProvider(HCPC);
unsigned Ret;
if (!::CryptGenRandom(CryptoProvider, sizeof(Ret),
reinterpret_cast<BYTE *>(&Ret)))
- report_fatal_error("Could not generate a random number");
+ ReportLastErrorFatal("Could not generate a random number");
return Ret;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14583.39958.patch
Type: text/x-patch
Size: 1053 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20151111/a87321a2/attachment.bin>
More information about the cfe-commits
mailing list