#45301 [Opn]: Serious flaw in random related functions and possibly file or memory corruption

From: Date: Wed, 02 Jul 2008 11:47:39 +0000
Subject: #45301 [Opn]: Serious flaw in random related functions and possibly file or memory corruption
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-126195@lists.php.net to get a copy of this message
ID: 45301 Updated by: jani@php.net Reported By: payton2558 at googlemail dot com Status: Open Bug Type: Math related Operating System: Windows XP 32, Vista 32 PHP Version: 5.2.6 New Comment: See also bug #45302 Previous Comments: ------------------------------------------------------------------------ [2008-06-18 21:26:39] pajoye@php.net > What about merging a patch that circulated in @internals that made > rand() and alias to mt_rand() and be done with this ? Because it may not fix the problem? (see the other report today and two weeks ago). ------------------------------------------------------------------------ [2008-06-18 21:04:23] crrodriguez at suse dot de What about merging a patch that circulated in @internals that made rand() and alias to mt_rand() and be done with this ? ------------------------------------------------------------------------ [2008-06-18 19:40:10] payton2558 at googlemail dot com Here's the shortest version. Try varying the array_fill num parameter. Lower numbers appear to increase the randomness. Appears problem is array_rand interfering with the random seed but please investigate further than that as I'm certain I experienced this problem before ever using array_rand (rand(0,count($a)-1) works in its place and doesn't trigger bug in this example). <?php $a = array_fill(0, 100000, "word"); for ($i=0; $i<20; $i++) { array_rand($a); echo rand(1,9999)."\n"; } ?> ------------------------------------------------------------------------ [2008-06-18 18:06:09] sv4php at fmethod dot com Confirmed on Apache 2.2, Windows XP SP2 with PHP 5.2.6. Confirmed also without building files (just building the array directly in a loop). Requires Windows, doesn't seem to affect mt_rand(); ------------------------------------------------------------------------ [2008-06-18 16:20:47] pajoye@php.net On a related note: #45184 ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/45301 -- Edit this bug report at http://bugs.php.net/?id=45301&edit=1

« previous php.bugs (#126195) next »