From:             Marcel dot Glacki at stud dot fh-swf dot de
Operating system: any
PHP version:      5.2.9
PHP Bug Type:     Arrays related
Bug description:  Generated index is reset due to integer overflow

Description:
------------
The generated index normally has the highest integer value regarding all
integers it has encountered as indexes before. (And is automatically
increased by +1)

It is possible to reset this index (the internal pointer) not only by the
functions intended to do so (like reset()) but also by increasing it above
integers' max value (integer overflow).

Reproduce code:
---------------
<?php
$max_int = 2147483647; // Max value for integer on a 32-bit system
$arr = array();

$arr[1] = 'one'; // New index: 2
$arr[ $max_int ] = 'two'; // New index: -2147483648
$arr[0] = 'three'; // New index: 1 (already occupied with value 'foo')
$arr[]  = 'failure here'; // Warning: Cannot add element to the array as
the next element is already occupied.
?>


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

Reply via email to