openbsd-ports/databases/mongodb/patches/patch-db_nonce_cpp

22 lines
753 B
Plaintext
Raw Normal View History

$OpenBSD: patch-db_nonce_cpp,v 1.2 2011/10/03 16:38:21 fgsch Exp $
--- db/nonce.cpp.orig Sun Sep 11 15:09:34 2011
+++ db/nonce.cpp Sun Sep 18 21:35:45 2011
@@ -42,7 +42,7 @@ namespace mongo {
massert( 10353 , "can't open dev/urandom", _devrandom->is_open() );
#elif defined(_WIN32)
srand(curTimeMicros()); // perhaps not relevant for rand_s but we might want elsewhere anyway
-#else
+#elif !defined(__openbsd__)
srandomdev();
#endif
@@ -63,6 +63,8 @@ namespace mongo {
assert( rand_s(&a) == 0 );
assert( rand_s(&b) == 0 );
n = (((unsigned long long)a)<<32) | b;
+#elif defined(__openbsd__)
+ n = arc4random();
#else
n = (((unsigned long long)random())<<32) | random();
#endif