Skip to content

Commit aeacb68

Browse files
committed
Use SecRandom only on 10.7+
1 parent 922052f commit aeacb68

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/sqlite3mc_amalgamation.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279979,6 +279979,8 @@ static size_t entropy(void* buf, size_t n)
279979279979
#ifndef RNDGETENTCNT
279980279980
#define RNDGETENTCNT _IOR('R', 0x00, int)
279981279981
#endif
279982+
#elif defined(__APPLE__)
279983+
#include <AvailabilityMacros.h>
279982279984
#endif
279983279985

279984279986
/* Returns the number of urandom bytes read (either 0 or n) */
@@ -280041,13 +280043,13 @@ static size_t read_urandom(void* buf, size_t n)
280041280043
return 0;
280042280044
}
280043280045

280044-
#if defined(__APPLE__)
280046+
#if defined(__APPLE__) && MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
280045280047
#include <Security/SecRandom.h>
280046280048
#endif
280047280049

280048280050
static size_t entropy(void* buf, size_t n)
280049280051
{
280050-
#if defined(__APPLE__)
280052+
#if defined(__APPLE__) && MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
280051280053
if (SecRandomCopyBytes(kSecRandomDefault, n, (uint8_t*) buf) == 0)
280052280054
return n;
280053280055
#elif defined(__linux__) && defined(SYS_getrandom)

0 commit comments

Comments
 (0)