|  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: -
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.
Block user comment
Status: Assign to:
Bug Type:
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
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"


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


AllCommentsChangesGit/SVN commitsRelated reports
 [2017-01-09 05:34 UTC]
Automatic comment on behalf of krakjoe
Log: Fixed bug #72979 money_format stores wrong length on AIX
 [2017-01-09 05:34 UTC]
-Status: Open +Status: Closed
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sun Mar 26 03:03:47 2023 UTC