Skip to content

Commit a505c99

Browse files
committed
fix(apple): SecRandomCopyBytes instead of arc4random_buf
1 parent c2526cf commit a505c99

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/utils.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
#if defined(__linux__) || defined(__ANDROID__)
2020
#include <sys/random.h>
2121
#endif
22+
#if defined(__APPLE__)
23+
#include <Security/Security.h>
24+
#endif
2225
#endif
2326

2427
#ifndef SQLITE_CORE
@@ -49,8 +52,8 @@ int cloudsync_uuid_v7 (uint8_t value[UUID_LEN]) {
4952
#ifdef _WIN32
5053
if (BCryptGenRandom(NULL, (BYTE*)value, UUID_LEN, BCRYPT_USE_SYSTEM_PREFERRED_RNG) != STATUS_SUCCESS) return -1;
5154
#elif defined(__APPLE__)
52-
// Use arc4random_buf for macOS/iOS
53-
arc4random_buf(value, UUID_LEN);
55+
// Use SecRandomCopyBytes for macOS/iOS
56+
if (SecRandomCopyBytes(kSecRandomDefault, UUID_LEN, value) != errSecSuccess) return -1;
5457
#else
5558
if (getentropy(value, UUID_LEN) != 0) return -1;
5659
#endif

0 commit comments

Comments
 (0)