mirror of
https://git.FreeBSD.org/ports.git
synced 2024-11-28 01:06:17 +00:00
95 lines
2.9 KiB
Plaintext
95 lines
2.9 KiB
Plaintext
|
diff --git configure.in configure.in
|
||
|
index 7bed45f..053de17 100644
|
||
|
--- configure.in
|
||
|
+++ configure.in
|
||
|
@@ -3166,6 +3166,7 @@ AC_CHECK_FUNCS(random strerror lchown fc
|
||
|
AC_CHECK_FUNCS(statvfs64 statvfs statfs64 statfs)
|
||
|
AC_CHECK_FUNCS(flockfile getpagesize)
|
||
|
AC_CHECK_FUNCS(localtime_r strtok_r)
|
||
|
+AC_CHECK_FUNCS(arc4random arc4random_buf)
|
||
|
|
||
|
dnl check for clock_gettime(), the CLOCK_MONOTONIC clock
|
||
|
AC_CACHE_CHECK(for clock_gettime(CLOCK_MONOTONIC),
|
||
|
diff --git xpcom/base/nsUUIDGenerator.cpp xpcom/base/nsUUIDGenerator.cpp
|
||
|
index 0687344..ca3ff8b 100644
|
||
|
--- xpcom/base/nsUUIDGenerator.cpp
|
||
|
+++ xpcom/base/nsUUIDGenerator.cpp
|
||
|
@@ -15,6 +15,10 @@
|
||
|
|
||
|
#include "nsUUIDGenerator.h"
|
||
|
|
||
|
+#ifdef ANDROID
|
||
|
+extern "C" NS_EXPORT void arc4random_buf(void *, size_t);
|
||
|
+#endif
|
||
|
+
|
||
|
using namespace mozilla;
|
||
|
|
||
|
NS_IMPL_ISUPPORTS1(nsUUIDGenerator, nsIUUIDGenerator)
|
||
|
@@ -34,7 +38,7 @@ nsUUIDGenerator::Init()
|
||
|
// We're a service, so we're guaranteed that Init() is not going
|
||
|
// to be reentered while we're inside Init().
|
||
|
|
||
|
-#if !defined(XP_WIN) && !defined(XP_MACOSX) && !defined(ANDROID)
|
||
|
+#if !defined(XP_WIN) && !defined(XP_MACOSX) && !defined(HAVE_ARC4RANDOM)
|
||
|
/* initialize random number generator using NSPR random noise */
|
||
|
unsigned int seed;
|
||
|
|
||
|
@@ -67,7 +71,7 @@ nsUUIDGenerator::Init()
|
||
|
return NS_ERROR_FAILURE;
|
||
|
#endif
|
||
|
|
||
|
-#endif /* non XP_WIN and non XP_MACOSX */
|
||
|
+#endif /* non XP_WIN and non XP_MACOSX and non ARC4RANDOM */
|
||
|
|
||
|
return NS_OK;
|
||
|
}
|
||
|
@@ -114,13 +118,16 @@ nsUUIDGenerator::GenerateUUIDInPlace(nsID* id)
|
||
|
* back to it; instead, we use the value returned when we called
|
||
|
* initstate, since older glibc's have broken setstate() return values
|
||
|
*/
|
||
|
-#ifndef ANDROID
|
||
|
+#ifndef HAVE_ARC4RANDOM
|
||
|
setstate(mState);
|
||
|
#endif
|
||
|
|
||
|
+#ifdef HAVE_ARC4RANDOM_BUF
|
||
|
+ arc4random_buf(id, sizeof(nsID));
|
||
|
+#else /* HAVE_ARC4RANDOM_BUF */
|
||
|
size_t bytesLeft = sizeof(nsID);
|
||
|
while (bytesLeft > 0) {
|
||
|
-#ifdef ANDROID
|
||
|
+#ifdef HAVE_ARC4RANDOM
|
||
|
long rval = arc4random();
|
||
|
const size_t mRBytes = 4;
|
||
|
#else
|
||
|
@@ -141,6 +148,7 @@ nsUUIDGenerator::GenerateUUIDInPlace(nsID* id)
|
||
|
|
||
|
bytesLeft -= toWrite;
|
||
|
}
|
||
|
+#endif /* HAVE_ARC4RANDOM_BUF */
|
||
|
|
||
|
/* Put in the version */
|
||
|
id->m2 &= 0x0fff;
|
||
|
@@ -150,7 +158,7 @@ nsUUIDGenerator::GenerateUUIDInPlace(nsID* id)
|
||
|
id->m3[0] &= 0x3f;
|
||
|
id->m3[0] |= 0x80;
|
||
|
|
||
|
-#ifndef ANDROID
|
||
|
+#ifndef HAVE_ARC4RANDOM
|
||
|
/* Restore the previous RNG state */
|
||
|
setstate(mSavedState);
|
||
|
#endif
|
||
|
diff --git xpcom/base/nsUUIDGenerator.h xpcom/base/nsUUIDGenerator.h
|
||
|
index 6a24212..68ed6f2 100644
|
||
|
--- xpcom/base/nsUUIDGenerator.h
|
||
|
+++ xpcom/base/nsUUIDGenerator.h
|
||
|
@@ -27,7 +27,7 @@ private:
|
||
|
protected:
|
||
|
|
||
|
mozilla::Mutex mLock;
|
||
|
-#if !defined(XP_WIN) && !defined(XP_MACOSX) && !defined(ANDROID)
|
||
|
+#if !defined(XP_WIN) && !defined(XP_MACOSX) && !defined(HAVE_ARC4RANDOM)
|
||
|
char mState[128];
|
||
|
char *mSavedState;
|
||
|
uint8_t mRBytes;
|