php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72979 money_format stores wrong lenght value on AIX
Submitted: 2016-08-30 15:59 UTC Modified: -
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:-1 (-100.0%)
From: matthieu dot sarter dot external at atos dot net Assigned:
Status: Closed Package: Strings related
PHP Version: 7.0.10 OS: AIX
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: matthieu dot sarter dot external at atos dot net
New email:
PHP Version: OS:

 

 [2016-08-30 15:59 UTC] matthieu dot sarter dot external at atos dot net
Description:
------------
On AIX strfmon seems to include the terminating \0 in the length returned by strfmon, despite the documentation and the Open Group specifications indicating it is not included.

PHP's money_format function uses the value returned by strfmon as the length for the new ZSTR, so this error is also present when using PHP on AIX.

The attached patch fixes this issue on PHP side, by using strlen after strfmon to get the size without the trailing \0 (tested with PHP 7.0.3, 7.0.7, 7.0.9 and 7.0.10 on AIX 6.1).


Test script:
---------------
// From ext/standard/tests/strings/moneyformat.phpt
setlocale(LC_MONETARY, 'en_US');
var_dump( money_format("X%nY", 3.1415));

Expected result:
----------------
string(7) "X$3.14Y"

Actual result:
--------------
string(8) "X$3.14Y"

Patches

php-7.0.3-aix-strfmon.patch (last revision 2016-08-30 15:59 UTC by matthieu dot sarter dot external at atos dot net)

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-01-09 05:34 UTC] krakjoe@php.net
Automatic comment on behalf of krakjoe
Revision: http://git.php.net/?p=php-src.git;a=commit;h=8dd523a21604bfb0c8ac70367396507ce9fe77cb
Log: Fixed bug #72979 money_format stores wrong length on AIX
 [2017-01-09 05:34 UTC] krakjoe@php.net
-Status: Open +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 16 14:01:29 2024 UTC