From:             payton2558 at googlemail dot com
Operating system: Windows XP 32, Vista 32
PHP version:      5.2.6
PHP Bug Type:     Unknown/Other Function
Bug description:  Serious flaw in random related functions and possibly file or 
memory corruption

Description:
------------
The reproduce code demonstrates the bug. You can modify the code in
different ways to affect the severity of the output.

Appears to require Windows.
Please note I have tested on 2 different machines and 3 versions of php. I
have also confirmed this with a couple of users on IRC.

mt_rand may also be affected but not as badly

Unrelated: bugs.php your CAPTCHA system is the worst I could ever expect
for a programming related group

Reproduce code:
---------------
<?php
function RandomNumber() {
        
        $word1 = file('word1.txt');      // word1 and word2.txt can be made by
fwriting "word\n" 50000 times. Different filesizes affect bug.
        $word2 = file('word2.txt');
                
        $rword1 = trim($word1[array_rand($word1)]);
        $rword2 = trim($word2[array_rand($word2)]);
        
        $rnum = rand(1,999);    
        
        return $rnum;
}

for ($i=0; $i<20; $i++) {
        
        echo RandomNumber()."\n";
}
?>

Expected result:
----------------
20 random looking numbers

Actual result:
--------------
20 identical numbers or in other cases, severely unrandom numbers

-- 
Edit bug report at http://bugs.php.net/?id=45301&edit=1
-- 
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=45301&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=45301&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=45301&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=45301&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=45301&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=45301&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=45301&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=45301&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=45301&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=45301&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=45301&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=45301&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=45301&r=globals
PHP 4 support discontinued:   http://bugs.php.net/fix.php?id=45301&r=php4
Daylight Savings:             http://bugs.php.net/fix.php?id=45301&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=45301&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=45301&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=45301&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=45301&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=45301&r=mysqlcfg

Reply via email to