From:             shm
Operating system: 
PHP version:      trunk-SVN-2011-11-19 (SVN)
Package:          BC math related
Bug Type:         Bug
Bug description:bcscale related problem on 64bits platforms

Description:
------------
bcscale uses long typed variable to store scale passed further to bclib
calls. Unfortunately bclib uses int type for scale parameter, thus large
long numbers (which uses 8 bytes on 64 bits platforms) could be casted to
negative number and cause memory corruption as a result of pointer
arithmetic with scale param.

Test script:
---------------
<?php
$var48 = bcscale(634314234334311);
$var67 = bcsqrt(false);
$var414 = bcadd(false,null,10);
die('ALIVE');
?>

Expected result:
----------------
ALIVE

Actual result:
--------------
$ php
<?php
$var48 = bcscale(634314234334311);
$var67 = bcsqrt(false);
$var414 = bcadd(false,null,10);
die('ALIVE');
?>^D
Segmentation fault: 11 (core dumped)

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

Reply via email to