r40493 - in /trunk/libmath-random-perl/debian/patches: ./ random-seed.patch series

jawnsy-guest at users.alioth.debian.org jawnsy-guest at users.alioth.debian.org
Wed Jul 22 15:08:42 UTC 2009


Author: jawnsy-guest
Date: Wed Jul 22 15:08:34 2009
New Revision: 40493

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=40493
Log:
Add the patches :-)

Added:
    trunk/libmath-random-perl/debian/patches/
    trunk/libmath-random-perl/debian/patches/random-seed.patch
    trunk/libmath-random-perl/debian/patches/series

Added: trunk/libmath-random-perl/debian/patches/random-seed.patch
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libmath-random-perl/debian/patches/random-seed.patch?rev=40493&op=file
==============================================================================
--- trunk/libmath-random-perl/debian/patches/random-seed.patch (added)
+++ trunk/libmath-random-perl/debian/patches/random-seed.patch Wed Jul 22 15:08:34 2009
@@ -1,0 +1,60 @@
+Description: Update seeding algorithm
+ By default, this algorithm uses localtime to seed the random number
+ generator, which provides poor randomness when Perl is executed many
+ times sequentially. This patch replaces that with Don Armstrong's
+ proposed solution, Perl_seed. See BTS#537952 for details.
+Origin: vendor
+Author: Jonathan Yu <frequency at cpan.org>
+Bug: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=537952
+Bug-CPAN: https://rt.cpan.org/Ticket/Display.html?id=48080
+Forwarded: yes
+--- a/Random.pm
++++ b/Random.pm
+@@ -73,7 +73,7 @@
+ 
+ 
+ ### set seeds by default
+-salfph(scalar(localtime()));
++set_default_seed(scalar localtime);
+ 
+ #####################################################################
+ #		      RANDOM DEVIATE GENERATORS                     #
+--- a/Random.xs
++++ b/Random.xs
+@@ -11,6 +11,22 @@
+ #include "randlib.h"
+ #include "helper.h"
+ 
++#ifdef Perl_seed
++/* For whatever reason, the random seeds need to be in 1..2^30; the below will
++ * be uniformly distributed assuming the seed value is uniformly distributed.
++ *
++ * This approach isn't cryptographically secure. Consider using /dev/random
++ * or Math::TrulyRandom to get some real entropy.
++ */
++#define Perl_get_seed (long)(Perl_seed(aTHX) % 1073741824L)
++#else
++/* If we don't support seeds, return 0 so we can fall back to localtime for
++ * default seeding. There's a chance Perl_seed will return 0 and mask this,
++ * but in that case the data should still be "random enough" anyway.
++ */
++#define Perl_get_seed 0L
++#endif /* Perl_seed */
++
+ static int
+ not_here(s)
+ char *s;
+@@ -38,6 +54,13 @@
+ 
+ MODULE = Math::Random		PACKAGE = Math::Random		
+ 
++void
++set_default_seed(long time)
++	PREINIT:
++	long seed;
++	CODE:
++	seed = Perl_get_seed || time;
++	setall(seed, time);
+ 
+ double
+ genbet (aa,bb)

Added: trunk/libmath-random-perl/debian/patches/series
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libmath-random-perl/debian/patches/series?rev=40493&op=file
==============================================================================
--- trunk/libmath-random-perl/debian/patches/series (added)
+++ trunk/libmath-random-perl/debian/patches/series Wed Jul 22 15:08:34 2009
@@ -1,0 +1,1 @@
+random-seed.patch




More information about the Pkg-perl-cvs-commits mailing list