Răsfoiți Sursa

iOS: Don't use getentropy() since it's disallowed in the App Store.

Reported by MoNTE48.
Mike Pall 4 ani în urmă
părinte
comite
787736990a
1 a modificat fișierele cu 9 adăugiri și 3 ștergeri
  1. 9 3
      src/lj_prng.c

+ 9 - 3
src/lj_prng.c

@@ -109,10 +109,16 @@ static PRGR libfunc_rgr;
 #include <sys/syscall.h>
 #include <sys/syscall.h>
 #else
 #else
 
 
-#if LJ_TARGET_OSX
+#if LJ_TARGET_OSX && !LJ_TARGET_IOS
+/*
+** In their infinite wisdom Apple decided to disallow getentropy() in the
+** iOS App Store. Even though the call is common to all BSD-ish OS, it's
+** recommended by Apple in their own security-related docs, and, to top
+** off the foolery, /dev/urandom is handled by the same kernel code,
+** yet accessing it is actually permitted (but less efficient).
+*/
 #include <Availability.h>
 #include <Availability.h>
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200 || \
-    __IPHONE_OS_VERSION_MIN_REQUIRED >= 100000
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
 #define LJ_TARGET_HAS_GETENTROPY	1
 #define LJ_TARGET_HAS_GETENTROPY	1
 #endif
 #endif
 #elif LJ_TARGET_BSD || LJ_TARGET_SOLARIS || LJ_TARGET_CYGWIN
 #elif LJ_TARGET_BSD || LJ_TARGET_SOLARIS || LJ_TARGET_CYGWIN