From 70a0a422b73699f584ae3fbef7e0913d93dd94d8 Mon Sep 17 00:00:00 2001 From: Kaleb Murphy Date: Mon, 10 Nov 2008 21:53:30 +0000 Subject: [PATCH] Removed all instances of srand. This is called implicitily by rand and be dangerous if called mulitple times by the same process. --- docs/changelog/7.x.x.txt | 2 +- lib/WebGUI/Asset/Wobject/Survey/ResponseJSON.pm | 2 +- lib/WebGUI/Macro/RandomAssetProxy.pm | 1 - lib/WebGUI/Macro/RandomThread.pm | 2 -- lib/WebGUI/Session/Id.pm | 1 - lib/WebGUI/Storage/Image.pm | 1 - 6 files changed, 2 insertions(+), 7 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 8aa13ece2..82c0c22a2 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -13,7 +13,7 @@ - added: Delete columns from DataTable - fixed: Now more than one DataTable can be put on a page - fixed #9002: add a variant in admin product view misses i18n link - + - fixed #9034: Removed all instances of srand. This is called implicitily by rand and be dangerous if called mulitple times by the same process. 7.6.2 - fixed: not allowed to add calendar events if in can edit group but not can add event group - sped up lineage changes significantly diff --git a/lib/WebGUI/Asset/Wobject/Survey/ResponseJSON.pm b/lib/WebGUI/Asset/Wobject/Survey/ResponseJSON.pm index 58ca2c8d9..22ccc9f86 100644 --- a/lib/WebGUI/Asset/Wobject/Survey/ResponseJSON.pm +++ b/lib/WebGUI/Asset/Wobject/Survey/ResponseJSON.pm @@ -34,7 +34,7 @@ sub createSurveyOrder{ my $self = shift; my $order; my $qstarting = 0; - +$self->log('wtf am I faling for'); for(my $s = 0; $s <= $#{$self->survey->sections()}; $s++){ #create question order for section my @qorder; diff --git a/lib/WebGUI/Macro/RandomAssetProxy.pm b/lib/WebGUI/Macro/RandomAssetProxy.pm index 3f3806bdc..8f0173b3b 100644 --- a/lib/WebGUI/Macro/RandomAssetProxy.pm +++ b/lib/WebGUI/Macro/RandomAssetProxy.pm @@ -41,7 +41,6 @@ sub process { if (defined $asset) { my $children = $asset->getLineage(["children"]); #randomize; - srand; my $randomAssetId = $children->[rand(scalar(@{$children}))]; my $randomAsset = WebGUI::Asset->newByDynamicClass($session,$randomAssetId); if (defined $randomAsset) { diff --git a/lib/WebGUI/Macro/RandomThread.pm b/lib/WebGUI/Macro/RandomThread.pm index 65170504b..fa19470ef 100644 --- a/lib/WebGUI/Macro/RandomThread.pm +++ b/lib/WebGUI/Macro/RandomThread.pm @@ -60,8 +60,6 @@ URL of the template to use to display the random thread. Must be a valid URL wit sub process { my $session = shift; my ($startURL, $relatives, $templateURL) = @_; - # Seed the randomizer: - srand; # Set defaults (default template is set by id later): $startURL ||= 'home'; diff --git a/lib/WebGUI/Session/Id.pm b/lib/WebGUI/Session/Id.pm index 968499bb5..1265f9ddf 100644 --- a/lib/WebGUI/Session/Id.pm +++ b/lib/WebGUI/Session/Id.pm @@ -101,7 +101,6 @@ A reference to the current session. sub new { my $class = shift; my $session = shift; - srand; bless {_session=>$session}, $class; } diff --git a/lib/WebGUI/Storage/Image.pm b/lib/WebGUI/Storage/Image.pm index da357d183..ca1c18b9e 100644 --- a/lib/WebGUI/Storage/Image.pm +++ b/lib/WebGUI/Storage/Image.pm @@ -73,7 +73,6 @@ sub addFileFromCaptcha { my $self = shift; my $error = ""; my $challenge; - srand; $challenge.= ('A'..'Z')[rand(26)] foreach (1..6); my $filename = "captcha.".$self->session->id->generate().".gif"; my $image = $graphicsPackage->new();