Bug #66183 [NEW]: Converting large strings to floats

From: Date: Wed, 27 Nov 2013 14:17:43 +0000
Subject: Bug #66183 [NEW]: Converting large strings to floats
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-182963@lists.php.net to get a copy of this message
From: aatallah at stanford dot edu Operating system: Mac OS X 10.9 PHP version: Irrelevant Package: Strings related Bug Type: Bug Bug description:Converting large strings to floats Description: ------------ I'm using PHP 5.4.17 (cli) (built: Aug 25 2013 02:03:38), the default shipped by Apple now. See the test script. When a string-representation of a decimal is large enough, converting it to a float causes "Fatal error: Balloc() allocation exceeds list boundary in php shell code on line 1" and terminates the script. This is similar to Ruby's bug, publicized at https://www.ruby-lang.org/en/news/2013/11/22/heap-overflow-in-floating-point-parsing-cve-2013-4164/. Ruby fixed this by avoiding the Bigint freelist in Balloc; perhaps PHP should do something better than having a hard cutoff for k in Balloc. Test script: --------------- echo floatval("1.".str_repeat("1", 300000)); Expected result: ---------------- 1.1111111111111, which is the output of echo floatval("1.".str_repeat("1", 300)); Actual result: -------------- Fatal error: Balloc() allocation exceeds list boundary in php shell code on line 1 -- Edit bug report at https://bugs.php.net/bug.php?id=66183&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=66183&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=66183&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=66183&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=66183&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=66183&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=66183&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=66183&r=needscript Try newer version: https://bugs.php.net/fix.php?id=66183&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=66183&r=support Expected behavior: https://bugs.php.net/fix.php?id=66183&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=66183&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=66183&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=66183&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=66183&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=66183&r=dst IIS Stability: https://bugs.php.net/fix.php?id=66183&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=66183&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=66183&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=66183&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=66183&r=mysqlcfg

« previous php.bugs (#182963) next »