php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #62112 Regression in number_format() in PHP 5.4
Submitted: 2012-05-22 20:17 UTC Modified: 2012-05-23 09:38 UTC
From: lstrojny@php.net Assigned: cataphract (profile)
Status: Closed Package: Math related
PHP Version: 5.4.3 OS: Linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: lstrojny@php.net
New email:
PHP Version: OS:

 

 [2012-05-22 20:17 UTC] lstrojny@php.net
Description:
------------
In PHP 5.3.X, passing a null byte as decimal point lead to no decimal point at 
all. This is not so much problematic for userland, as for C extensions. For 
examlpe phpredis uses it internally (see 
https://github.com/nicolasff/phpredis/blob/master/redis.c#L3665) to format a 
number. This worked fine in PHP 5.3, but with PHP 5.4 only the first character 
until the first decimal point is returned.

Test script:
---------------
php -r 'var_dump(number_format(2000.1, 0, ".", "\x00"));'

Expected result:
----------------
string(4) "2000"

Actual result:
--------------
string(1) "2"

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-05-22 21:28 UTC] lstrojny@php.net
See this pull request for the proposed fix: https://github.com/php/php-
src/pull/87
 [2012-05-22 21:35 UTC] lstrojny@php.net
Sorry, link is broken: https://github.com/php/php-src/pull/87
 [2012-05-23 09:38 UTC] cataphract@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.


 [2012-05-23 09:38 UTC] cataphract@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: cataphract
 [2012-05-23 09:39 UTC] cataphract@php.net
Automatic comment on behalf of cataphract
Revision: http://git.php.net/?p=php-src.git;a=commit;h=3e62aae1b456440328af4153524e22679b84f68a
Log: Fix bug #62112: number_format() is not binary safe
 [2012-07-18 06:19 UTC] stas@php.net
Automatic comment on behalf of stas
Revision: http://git.php.net/?p=php-src.git;a=commit;h=a66b5c9a289f5bfc392e1fd9ae13981e84a465ac
Log: Revert "Fix bug #62112: number_format() is not binary safe"
 [2014-10-07 23:25 UTC] stas@php.net
Automatic comment on behalf of cataphract
Revision: http://git.php.net/?p=php-src-security.git;a=commit;h=3e62aae1b456440328af4153524e22679b84f68a
Log: Fix bug #62112: number_format() is not binary safe
 [2014-10-07 23:36 UTC] stas@php.net
Automatic comment on behalf of cataphract
Revision: http://git.php.net/?p=php-src-security.git;a=commit;h=3e62aae1b456440328af4153524e22679b84f68a
Log: Fix bug #62112: number_format() is not binary safe
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 28 12:01:28 2024 UTC