From 610688e410a0b544d5dfd9de0bc50fab090bd5f3 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Sat, 13 Jul 2024 13:21:50 +0100 Subject: Use getentropy() from POSIX 2024 if it is available. --- src/helperfuncs.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/helperfuncs.cpp') diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp index aeaad9ab9..16e97da1b 100644 --- a/src/helperfuncs.cpp +++ b/src/helperfuncs.cpp @@ -456,7 +456,11 @@ unsigned long InspIRCd::GenRandomInt(unsigned long max) const // This is overridden by a higher-quality algorithm when TLS support is loaded void InspIRCd::DefaultGenRandom(char* output, size_t max) { -#if defined HAS_ARC4RANDOM_BUF +#ifdef HAS_GETENTROPY + if (getentropy(output, max) == 0) + return; +#endif +#ifdef HAS_ARC4RANDOM_BUF arc4random_buf(output, max); #else static std::random_device device; -- cgit v1.3.1-10-gc9f91