From d93e916d0cd3cf69e4484fe6d9929fbf57475567 Mon Sep 17 00:00:00 2001 From: Niklas Poslovski Date: Tue, 5 Sep 2023 23:34:28 +0200 Subject: [PATCH] AK: Use arc4random_buf() for Random on all BSDs --- AK/Random.h | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/AK/Random.h b/AK/Random.h index 5cb2054db86..0a0ac1c5ff2 100644 --- a/AK/Random.h +++ b/AK/Random.h @@ -16,15 +16,11 @@ # include #endif -#if defined(AK_OS_MACOS) -# include -#endif - namespace AK { inline void fill_with_random([[maybe_unused]] Bytes bytes) { -#if defined(AK_OS_SERENITY) || defined(AK_OS_ANDROID) +#if defined(AK_OS_SERENITY) || defined(AK_OS_ANDROID) || defined(AK_OS_BSD_GENERIC) arc4random_buf(bytes.data(), bytes.size()); #elif defined(OSS_FUZZ) #else @@ -33,7 +29,7 @@ inline void fill_with_random([[maybe_unused]] Bytes bytes) byte = rand(); }; -# if defined(__unix__) or defined(AK_OS_MACOS) +# if defined(__unix__) // The maximum permitted value for the getentropy length argument. static constexpr size_t getentropy_length_limit = 256; auto iterations = bytes.size() / getentropy_length_limit;