mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 22:50:59 +01:00
Make sure that GetRandomBytes never fails
We're using GetRandomBytes in several contexts where it's either unwieldy to return an error, or an error would mean a fatal exception anyhow. @gmaxwell checked OpenSSL a while ago and discovered that it never actually fails, but it can't hurt to be a bit paranoid here.
This commit is contained in:
@@ -82,13 +82,12 @@ void RandAddSeedPerfmon()
|
||||
#endif
|
||||
}
|
||||
|
||||
bool GetRandBytes(unsigned char* buf, int num)
|
||||
void GetRandBytes(unsigned char* buf, int num)
|
||||
{
|
||||
if (RAND_bytes(buf, num) != 1) {
|
||||
LogPrintf("%s: OpenSSL RAND_bytes() failed with error: %s\n", __func__, ERR_error_string(ERR_get_error(), NULL));
|
||||
return false;
|
||||
assert(false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
uint64_t GetRand(uint64_t nMax)
|
||||
|
||||
Reference in New Issue
Block a user