Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 29 Apr 2001 23:45:26 -0700 (PDT)
From:      kiss@gizzywump.com
To:        FreeBSD-gnats-submit@freebsd.org
Cc:        kris@obsecurity.org, kiss@gizzywump.com
Subject:   ports/26979: ports/lang/lua patch
Message-ID:  <200104300645.f3U6jQU27162@kalamalka.gizzywump.com>

next in thread | raw e-mail | index | archive | help

>Number:         26979
>Category:       ports
>Synopsis:       lang/lua port patch to improve randomness
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          update
>Submitter-Id:   current-users
>Arrival-Date:   Sun Apr 29 23:50:02 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Richard Kiss
>Release:        FreeBSD 4.3-STABLE i386
>Organization:
>Environment:
System: FreeBSD kalamalka.gizzywump.com 4.3-STABLE FreeBSD 4.3-STABLE #1: Sun Apr 22 22:39:33 PDT 2001 root@kalamalka.gizzywump.com:/mnt/usr/obj/mnt/usr/src/sys/GIZZYWUMP i386

>Description:
	Patch by Kris Kennaway to use random/srandom rather than
	rand/srand to improve randomness.
>How-To-Repeat:
	N/A
>Fix:
Here is the patch:

--- /dev/null	Mon Apr 30 00:07:15 2001
+++ files/patch-ab	Mon Apr 30 00:06:33 2001
@@ -0,0 +1,20 @@
+--- src/lib/lmathlib.c.orig	Mon Apr 30 00:05:45 2001
++++ src/lib/lmathlib.c	Mon Apr 30 00:06:05 2001
+@@ -168,7 +168,7 @@
+ static int math_random (lua_State *L) {
+   /* the '%' avoids the (rare) case of r==1, and is needed also because on
+      some systems (SunOS!) "rand()" may return a value larger than RAND_MAX */
+-  double r = (double)(rand()%RAND_MAX) / (double)RAND_MAX;
++  double r = (double)(random()%RAND_MAX) / (double)RAND_MAX;
+   switch (lua_gettop(L)) {  /* check number of arguments */
+     case 0: {  /* no arguments */
+       lua_pushnumber(L, r);  /* Number between 0 and 1 */
+@@ -194,7 +194,7 @@
+ 
+ 
+ static int math_randomseed (lua_State *L) {
+-  srand(luaL_check_int(L, 1));
++  srandom(luaL_check_int(L, 1));
+   return 0;
+ }
+ 

>Release-Note:
>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-ports" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200104300645.f3U6jQU27162>