$OpenBSD: patch-kjs_math_object_cpp,v 1.5 2014/07/11 11:13:10 zhuk Exp $
More correct implementation of random() & Co., using arc4random().
--- kjs/math_object.cpp.orig	Sun Jun  8 15:41:32 2014
+++ kjs/math_object.cpp	Fri Jul 11 09:12:21 2014
@@ -138,7 +138,9 @@ JSValue *MathObjectImp::getValueProperty(ExecState *, 
 
 // ------------------------------ MathObjectImp --------------------------------
 
+#if !HAVE_ARC4RANDOM
 static bool randomSeeded = false;
+#endif
 
 MathFuncImp::MathFuncImp(ExecState* exec, int i, int l, const Identifier& name)
   : InternalFunctionImp(static_cast<FunctionPrototype*>(exec->lexicalInterpreter()->builtinFunctionPrototype()), name)
@@ -228,11 +230,15 @@ JSValue *MathFuncImp::callAsFunction(ExecState *exec, 
       result = ::pow(arg, arg2);
     break;
   case MathObjectImp::Random:
+#if HAVE_ARC4RANDOM
+      result = (double)arc4random() / (double)0xFFFFFFFF;
+#else
       if (!randomSeeded) {
           srand(static_cast<unsigned>(time(0)));
           randomSeeded = true;
       }
       result = (double)rand() / RAND_MAX;
+#endif
       break;
   case MathObjectImp::Round:
     if (signbit(arg) && arg >= -0.5)
